Reputation: 2017
Problem Statement:
I'm trying to get the datetime value from the table using some where conditions but it is giving exception as : LINQ to Entities does not recognize the method 'System.Object get_Item(System.String)' method, and this method cannot be translated into a store expression.
Linq Query what i'm trying :
Datetime PDate=(from p in db.PMaster
where p.ID == ID
&& p.PNumber == Num
select p.PDate).SingleOrDefault();
I'm trying to get Datetime column(PDate) value from the the db using linq and assigning it to variable.
What i'm doing wrong??
Upvotes: 1
Views: 102
Reputation: 2017
Solution:
Based on @Tim.Tang comment, following code snippet solved my problem
Datetime PDate=(from p in db.PMaster.AsEnumerable()
where p.ID == ID
&& p.PNumber == Num
select p.PDate).SingleOrDefault();
Upvotes: 2