My best guess without you telling us exactly what the error is, is that your query does not return a
tempUserCityHotelAccess
but an
IQueriable
or other similar data type. This is because you query could potentially return more than one result.
If you can guarantee that only a single object will be returned you can use
.Single()
, else you could use
.First()
of perhaps
.FirstOrDefault()
Here is a link to a stack overflow question on when to use
Find, First, Single
etc.
Entity Framework 4 Single vs First vs FirstOrDefault[
^]
int sessionUsrId = SessionVariables.intUSerID;
tempUserCityHotelAccess item = new tempUserCityHotelAccess();
tempUserCityHotelAccess temptable = (from t in db.tempUserCityHotelAccesses where t.IntUserId == (sessionUsrId) select t).Single();