1

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??

7
  • @TimSchmelter...its a datetime column mentioned in question Commented Aug 22, 2014 at 8:38
  • where do you use the PDate? Commented Aug 22, 2014 at 8:40
  • 1
    what if you try this ` db.PMaster.AsEnumerable()`? Commented Aug 22, 2014 at 8:42
  • You're sure this is all the code that's causing the problem? I can't see any indexing here, which is odd... what's the compile-time type of db.PMaster? Commented Aug 22, 2014 at 8:46
  • @Tim.Tang-Thanks making db.PMaster as db.PMaster.AsEnumerable() solved my problem. Commented Aug 22, 2014 at 8:50

1 Answer 1

2

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.