Lambda 表达式导航属性上的Where
下午好,
我有三个实体(涉及这个问题)
公司(ID等..) 公司地址(地址ID、公司ID、排名) AddressDetails(AddressID、街道、城市、州、邮政编码)
排名和公司 ID 不在 AddressDetails 中的原因是因为地址详细信息通过 ContactAddress 实体与联系人共享。
无论如何,我需要构建一个 IQueryable 给定一个 IQueryable 来检查字符串是否包含在城市(最终或状态)中。我想使用 Lambda 表达式,而不是 from c in Companies
语法...我尝试过
query = query.Select(c => c.Addresses.Where(a => a.AddressDetails.City.Contains(City)).Select(ca => ca.Company));
在此示例中,c.Addresses 是 CompanyAddress 的导航属性。
感谢您的帮助,
保罗
Good afternoon,
I have three entities (that concern this question)
Company (ID, etc..)
CompanyAddress (AddressID, CompanyID, Rank)
AddressDetails (AddressID, Street, City, State, Zip)
The reason Rank and company id aren't in the AddressDetails is because the address details are shared with contacts via a ContactAddress entity.
Anyway, I need to build an IQueryable given an IQueryable that will check if a string is contained in the City (and eventually or state). I'd like to use Lambda expressions not the from c in companies
syntax...I tried
query = query.Select(c => c.Addresses.Where(a => a.AddressDetails.City.Contains(City)).Select(ca => ca.Company));
In this example c.Addresses is the navigation property for CompanyAddress.
Thanks for any help,
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这会起作用:
我假设查询是
IQueryable
。I think that this will work:
I assume that query is
IQueryable<Company>
.