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

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -