I am currently trying to limit which users can access which groups, and am doing this by using linq. My problem occours when I am adding the relevant groups to the view.
The error I keep getting is:
LINQ to Entities does not recognize the method 'System.String GetUserId(System.Security.Principal.IIdentity)' method, and this method cannot be translated into a store expression
This is my code:
var groupUser = db.GroupUsers.Where(u => u.ApplicationUserId == User.Identity.GetUserId()).Select(gr => gr.GroupId);
pv.GroupList = db.Groups.Where(g => groupUser.Contains(g.Id)).ToList();
return View(pv);
User.Identity.GetUserId()into a variable. - Yacoub Massad