[英]C# How to access fields tables in joint tables in linq query?
Supposing i have 3 tables in the below picture that joined together.假设我在下图中有 3 个表连接在一起。 how can i access 'Email' field in 'Users' table in my query on 'UserReferralJoins' table ?
如何在“UserReferralJoins”表的查询中访问“用户”表中的“电子邮件”字段?
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);
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'.表中字段的名称非常重要我看到您的数据库中的连接字段名称是正确的,正如我在图片中看到的那样非常简单,您可以使用 linq 查询来获取您的目的,例如使用“userreferral”。 user and fetch the field of user table.
用户并获取用户表的字段。 if you want more help plz comment me.
如果您需要更多帮助,请评论我。
在您的选择查询中使用此模式
UserEmail =x.UserReferral.ReferralCode
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.