I am getting the following error when running the following query
public int getPinCount(int terminalId, ref int pinnumber)
{
using (var dbEntities = new DatabaseAccess.Schema.BMIEntityModel())
{
DateTime dateNow = DateTime.Now;
return (from pins in dbEntities.PinIds
where pin.TerminalID.Equals((int)terminalId)
&& pin.PinExpireDateTime < (DateTime)dateNow
select pins).Count();
}
return 0;
}
Unable to create a constant value of
type ‘System.Object’. Only primitive
types (‘such as Int32, String, and
Guid’) are supported in this context.
- TerminalId = int
- PinExpireDateTime = datetime
Any ideas?
If you’re comparing
intsin:pin.TerminalID.Equals((int)terminalId)cast it before query and use==.Assuming that
terminalIdis intI dont understand why are u casting
dateNowtoDateTimeit’s not needed since it’s alreadyDateTime.