c# - Linq to entities navigation properties -
in entity framework have 2 table (two entities): people , role 1 many relationship. in people tables have navigation property role:
//people.cs public virtual icollection<role> role { get; set; }
now want retrieve people have role 'barman'. how can achieve this? want use linq entities in query expression method. i've tried:
var listperson = (from p in sicontext.people p.role.name = 'barman' select p).tolist();
the problem cannot make p.ruolo.name because p.ruolo icollectiontype doesn't have property "name" (while entity role has property)
since role collection, need use any
var listperson = (from p in sicontext.people p.role.any(x => x.name == "barman") select p).tolist();
Comments
Post a Comment