c# - LINQ to Entities does not recognize the method 'System.String ToString(Int32)' -


hi using linq query throwing error linq entities not recognize method 'system.string tostring(int32)' method, , method cannot translated store expression.

        list<string> resultmap = (from item in mapresult                                   select convert.tostring(item.resultde)).tolist(); 

error throwing in below statement

        list<result_de> resultlist = (from result in db.result_de                                       result.isactive == "1"                                       && resultmap.contains(convert.tostring(convert.toint32(result.id)))                                       select result).tolist(); 

please tell me proper way of writing query.

you cannot use these conversion functions in linq entities statement, cannot translated sql, need conversions in memory. don't think need @ all.

if using resultmap resultlist, filtered results of id present in mapresult, following:

var resultlist = db.result_de     .where(r => r.isactive == "1" && mapresult.any(mr => mr.resultde == r.id));     .tolist(); 

if mapresult in-memory collection, instead of iqueryable attached db context, need following:

var resultids = mapresult.select(mr => mr.resultde).tolist(); var resultlist = db.result_de     .where(r => r.isactive == "1" && resultids.contains(r.id));     .tolist(); 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -