LINQ to Entities does not recognize the method 'System.DateTime GetValueOrDefault()'
i am facing this error when i try to add my property in a model of type date time whose value is retrieved from global function
Ex: LastModifiedDate = Global.function name(param1,param2).GetValueOrDefault,
Naimish MakwanaPosted Mar 10, 2023, 3:50 AM
Hello Basit,
Try below solution
Thanks
Naimish Makwana
Tuhin PaulPosted Mar 10, 2023, 8:01 PM
The reason this solution worked is because the null coalescing operator (??) is used to handle null values. In the code, the GetValueOrDefault() method is called on the result of the Global.function name(param1,param2) call, which is causing the error because LINQ to Entities does not recognize this method.
Sachin SinghPosted Mar 9, 2023, 4:39 PM
use this insted
Basit NisarPosted Mar 9, 2023, 2:41 PM
Any suggestion?