I am using LINQ and I want to call a method (e.g. checkOpenClose
) by passing parameters, and have it return true
/false
:
var model = (from account in _ctx.Account
where (...)
select new DetailVM
{
Id = account.Id,
Name = account.CompanyName,
OpenNow = checkOpenClose(account.MonOpen, account.MonClosed,
account.TueOpen, account.TueClosed,
account.WedOpen, account.WedClosed,
account.ThuOpen, account.ThuClosed,
account.FriOpen, account.FriClosed,
account.SatOpen, account.SatClosed,
account.SunOpen, account.SunClosed)
}).Tolist()
I get the following error:
LINQ to Entities does not recognize the method 'Boolean checkOpenClose (System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String, System.String)' method, and this method cannot be translated into a store expression.
What am I doing wrong?