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

[Solved] 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.

| | Linq

This is caused because of Where-Expression.
You should only use variables in there or call methods that can be translated to SQL.


First, save your Session value in a variable:


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

posts = db.Posts.Where(a => a.UserId == userId)

Then use userId in your Where-Expression.