LINQ to Entities does not recognize the method Int32 get_Item(Int32)

后端 未结 3 1265
广开言路
广开言路 2020-11-27 19:10

I am a newbie about entity framework and linq. My query is like that

var query = (from d in db.MYTABLE
             where d.RELID.Equals(myInts[0])
                 


        
3条回答
  •  星月不相逢
    2020-11-27 19:48

    The Linq query is ultimately transformed into an SQL query and LINQ doesn't know what to do with Session["UserName"] (that gets the "UserName" item).

    A common way to workaround this is just to use a local variable to which you'll assign Session["UserName"] and that you'll use in your Linq query...

    like

    string loggedUserName = Session["LogedUsername"].ToString();
    var userdetail = dc.faculties.Where(a => a.F_UserName.Equals(loggedUserName)).FirstOrDefault();
    

    reference http://mvc4asp.blogspot.in/

提交回复
热议问题