I have the following LINQ query:
//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"
};
I get the error "... does not support translating to SQL" When I remove a method call from the TotalCount column and assign a static value, it works fine. Looks liek LINQ cannot translate method call to tSQL
Can anyone help me with this?
thank
Source of the GetCount () method:
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;
source
share