While executing below linq query on controller, I got this error:
Opertor '==' cannot be applied to operands of type 'int?' and 'string'
Controller:
from t in db.ASN_ITEM
join t0 in db.ITEM_MASTER on t.ITEM_MASTER.ITEM_CODE equals t0.ITEM_CODE
where
t.REGION_ID == RegionId &&
(Status == "" || Status == "-1" || t.SCAN_STAT == Status)
Here type of t.SCAN_STAT
is int?
and type of variable status
is string
.
I have tried this one:
(Status == "" || Status == "-1" || SqlFunctions.StringConvert((double)t.SCAN_STAT) == Status)
But not fetching the desired data based on the condition.
When I tried (Status == "" || Status == "-1" || t.SCAN_STAT.ToString() == Status)
, I got this error:
LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.
These are the solutions I got from other sites. Now how can I solve this error?