【发布时间】:2020-01-16 04:59:18
【问题描述】:
我正在尝试使用三元表达式进行连接,如下所示。 “AddedSince”在模型中从添加客户的日期开始计算,期间是动态的,它是从 url 查询参数中选择的。
我想要实现的是检查是否在比请求的时间更短的时间内添加了此人,如果是,请使用 AdditionalSince 值。除了这个我不确定它是否正确之外,还有其他连接并且一切正常。错误是“int 不包含 CustomerId 的定义”
int period =6;
var query =( from bk in customers.....
join cu in db.Customers.Where(a=>a.MemberOk).Select(a => a.AddedSince < period ? a.AddedSince: period)
on bk.CustomerId equals cu.CustomerId into cuspd )
我可以在 linq 中以这种方式使用 Tenery 操作吗?如果是的话,我该怎么做。谢谢
【问题讨论】:
-
您将每个客户投射到一个 int 属性中,然后尝试加入
int.CustomerId。 -
What I am trying to achieve is to check if the person has been added at a shorter period than the period requested if so use the AddedSince value使用是什么意思?选择那个值?加入那个价值? -
我需要 customerId 和 AdditionalSince 或 Period 值来加入查询
标签: entity-framework linq join c#-4.0