Supposing i have 3 tables in the below picture that joined together. how can i access 'Email' field in 'Users' table in my query on 'UserReferralJoins' table ?
can any one help me?
var referalId = await _dbContext.UserReferrals.Where(x => x.UserId == CurrentUserId).Select(x => x.UserReferralId).FirstOrDefaultAsync();
var list = await _dbContext.UserReferralJoins
.Where(i => i.UserReferralId == referalId)
.Select(x => new
{
Id = x.UserReferralJoinId,
UserEmail = ???
x.JoinDate
}).ToListAsync(cancellationToken);
CodePudding user response:
Use this pattern in your select query
UserEmail =x.UserReferral.ReferralCode
CodePudding user response:
The name of field in your table is very important I see that your join field name is correct in your database as I see in picture very simply you can use linq query for fetching your purpose for example use 'userreferral'. user and fetch the field of user table. if you want more help plz comment me.