我有以下 LINQ 查询:
//myRepository.GetClients(); returns an IQueriable<>
var AllClients = myRepository.GetClients();
var ClientReports = from c in FirmECFIs
select new ClientReport
{
FirmSerialNumber = c.SerialNumber,
FirmName = c.Name,
Year = c.Year,
Month = c.Month,
CustID = c.CustID,
TotalCount =myRepository.GetCount(c.SerialNumber, billingYear, billingMonth),
TotalPrice = "0"
};
我收到一条错误消息,上面写着“...没有支持的 SQL 转换”,我从 TotalCount 列中删除了方法调用并分配了一个静态值,它可以正常工作。看起来 LINQ 无法将方法调用转换为 tSQL
谁能帮我解决这个问题?
谢谢
GetCount() 方法的来源:
public int GetCount(int SerialNumber, string billingYear, string billingMonth)
{
var Count = CreateDataContext().myView.Where(c => c.SerialNumber == SerialNumber)
.Where(c => c.Year == Convert.ToInt32(billingYear)).Where(c => c.Month == Convert.ToInt32(billingMonth));
return Count.ToList().Count;