c# .net Adsense ADO.NET Linq Viruses/security asp.net MVC JQuery Angular-js Node-js SEO Java C++ SQL API Networking vb.net .Net Css JavaScript Generics c#.Net entity framework HTML Website host Website Construction Guide HTTP tutorial W3C tutorial Web Services JSON Psychology Ionic framework Angular ReactJS Python Computer Android
Linq

LINQ to Entities does not recognize the method 'System.Object get_Item(System.String)' method, and this method cannot be translated into a store expression

| | ASP-NET , CSharp , Linq
ServerError in '/' Application.

LINQ to Entities doesnot recognize the method 'System.Object get_Item(System.String)'
method, andthis method cannot be translated into a store expression.

A Linq query is translated to SQL to be performed against the database. Make sure you need to assign session or form request to a variable first because that has no access to it, and use this variable in the query.

int userId = (int)Session["UserId"];

 var hasrecord = db.Submits
.Where(m =>m.Published == false && m.CreatedUserId ==userId)
.OrderByDescending(m => m.SubmitId);