I have these entities, ApplicationUser
, UserProvider
andPracticeProviders
. the relationship between ApplicationUser
andUserProvider
is one-to-many
and between the latter and
PracticeProviders
is one-to-many
as well. I am trying to select a record inApplicationUser
and its details from UserProvider
and subsequently the data fromPracticeProviders
.
publicclassApplicationUser:IdentityUser{publicstringFirstName{get;set;}publicstringLastName{get;set;}publicICollection<UserProvider>UserProviders{get;set;}publicApplicationUser(){UserProviders=newCollection<UserProvider>();}}publicclassUserProvider{publicstringUserId{get;set;}publicGuidProviderId{get;set;}publicPracticeProvidersProvider{get;set;}publicApplicationUserUser{get;set;}}publicclassPracticeProviders{publicPracticeProviders(){Id=Guid.NewGuid();}publicGuidId{get;set;}[Required]publicstringName{get;set;}publicstringAddress{get;set;}publicstringPhoneNumber{get;set;}publicICollection<UserProvider>UserProviders{get;set;}}
if I do,
publicasyncTask<ApplicationUser>GetUserDataByIdAsync(string userId){returnawaitthis.context.ApplicationUser.Include(user => user.UserProviders).Where(user => user.Id== userId).SingleOrDefaultAsync();}
I get only UserProviders
data only, How can I get the details of each member in the collection list?
I tried ThenInclude()
but I couldn't connect to deeper objects inPracticeProviders
.