c# - LINQ to Entities does not recognize the method 'Int32 Parse(System.String)' method, and this method cannot be translated into a store expression -


I am using unit framework, and I have a code that is taking a var and it is an i database .

  var record = reference. Nomination SingleLow Default (Row = & gt; Row.UUSID == Int. Purs (userid) and row.classId == int. Purse (class ID));   

Every time I try to run it, I get a rhis error "LINQ to Entities" does not recognize the 'intern 32 pars (system string.)' Method, and this method Can not translate into a store's expression. "

I have also tried well

  var records = reference. FirstOver Default (line = & gt; line.user id == convert.OINIT32 (userid) & amp; quote; class id == convert.OINIT32 (class idid));   

And what I found is this error message, "LINQ method does not recognize the INFO TOInt32 (System.String) method 'for the unit, and this method stores in the expression Can not translate

And in the end I also tried it, which I know is unusual, but it has worked in the past for similar situations.

  var record = context.enrollments. Singular default (line = & gt; line.user id == COMMENDALLEL.Synt & lt; int & gt; Convert type (userid) & amp; quote; classID == COMMODELLL.Synthesize  ConvertType (classID));   

In which I get this error, as you can see that I have tried different things to sewell and nothing is working, so any help would be great.

In Linq to Entity , you should use the methods in your query To run on your data base on your provider supported , change the expression tree .

All providers should support some methods by default called canonical functions (), and you can use your user defined function and stored procedures can be defined as . In addition to linq query () and (), you can use methods that are supported by providers and < Code> Expression trees which are in.

And in the end, about your question, you can convert UserID and ClassID before your query:

  var UID = int.Parse (UserID); var cid = int.Parse (ClassID); Var record = reference Nomination SingleLow Default (Row = & gt; LineUUSID == UID & Row; ClassID == CID);    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -