I’m trying to replicate the following SQL query in linq:
Select
l.*,
ISNULL( i.InterestPercentage,0)
as InterestPercentage
FROM properties l
LEFT JOIN interest i on i.ListingKey = l.ListingKey
Where i.userId = {0}
I don’t really have much to go with at the moment:
var results = from l in context.properties
join s in context.interest on l.ListingKey equals s.ListingKey
where s.userId == "";
This returns me a full join, but I’d like to return the properties with a single additional value, the InterestPercentage. I think I might need to create a new object that is all the columns of properties with an additional property of InterestPercentage. Then add select new MyObject { tons of property setters }.
Additionally though, I’m trying to expose this via Odata, would I lose the queryable ability by doing this?
You can try to return
Or create an object which will have similar structure as above. This will help you avoid all property setting.