c# - Error in Entity framework query (Missing cast) -


public list<projectimpacts> getprojectimpactsbyprojeactidandimpactname(string prefe , string impcname) {      string xim =  cecbcontext.impacts.first(i=>i.impt_name.contains(impcname)).impt_reference;      iqueryable<projectimpacts> query = c in cecbcontext.projectimpacts             join b in cecbcontext.impacts on c.impt_reference equals b.impt_reference                          c.proj_reference == prefe && c.impt_reference == xim             select b.impt_name;      list<projectimpacts> selectedimpacts = query.tolist(); //query.select(refe => new projectimpacts { impt_reference =   }).tolist();      return selectedimpacts; } 

i'm getting error in query:

cannot implicitly convert type 'system.linq.iqueryable' 'system.linq.iqueryable'. explicit conversion exists (are missing cast?)

this because query selects name @ end:

iqueryable<projectimpacts> query = c in cecbcontext.projectimpacts     join b in cecbcontext.impacts on c.impt_reference equals b.impt_reference                  c.proj_reference == prefe && c.impt_reference == xim     // select b.impt_name; // <<== replace this...     select c;              // <<== this. 

the type parameter t of generic iqueryable<t> corresponds type of object selected in query. since select name (which presumably string), got iqueriable<string>. once select c, projectimpacts, you'd iqueryable<projectimpacts> result


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -