【发布时间】:2013-02-11 03:57:41
【问题描述】:
我正在尝试在 linq 中复制以下 SQL 查询:
Select
l.*,
ISNULL( i.InterestPercentage,0)
as InterestPercentage
FROM properties l
LEFT JOIN interest i on i.ListingKey = l.ListingKey
Where i.userId = {0}
我现在真的没什么可做的:
var results = from l in context.properties
join s in context.interest on l.ListingKey equals s.ListingKey
where s.userId == "";
这会返回一个完整的连接,但我想返回带有单个附加值的属性,即InterestPercentage。我想我可能需要创建一个新对象,它是所有属性列以及一个额外的 InterestPercentage 属性。然后添加select new MyObject { tons of property setters }。
此外,我正试图通过 Odata 公开这一点,这样做是否会失去可查询的能力?
【问题讨论】:
标签: linq odata entity-framework-4.3