0

i have written the following code

var resumeedit=(from t in db.Resumes where t.User.UserID==theUserID && t.ResumeID==theResumeID select t).Select(t=> new EditResumes
                 {
                     Iswizard=t.isWizard,
                     Resumeid=t.ResumeID.ToString()
                 }).First();
             EditResumes ed = (EditResumes)resumeedit;

and it is giving error LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.

2 Answers 2

1

this line

Resumeid=t.ResumeID.ToString()

what happens when you make it

Resumeid=t.ResumeID

?

or simple do:

select new { t.ResumeID, t.isWizard }
Sign up to request clarification or add additional context in comments.

1 Comment

With your first suggestion, the code won't compile. With your second, the cast in the second line fails.
0

Like the message says, L2E doesn't do .ToString(). So use .AsEnumerable() to bring it into L2O:

var resumeedit= (from t in db.Resumes 
                 where t.User.UserID==theUserID && t.ResumeID==theResumeID
                 select t)
                .AsEnumerable()
                .Select(t=> new EditResumes
                 {
                     Iswizard=t.isWizard,
                     Resumeid=t.ResumeID.ToString()
                 }).First();

This cast should be unnecessary:

 EditResumes ed = (EditResumes)resumeedit;

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.