Last post Feb 05, 2020 07:22 PM by byuan
Feb 04, 2020 04:36 AM|byuan|LINK
I have one entity, Property, with a value object Address, by using EF Core Code First, I got a table of Property and Address with a primary key point to the PropertyId. What I need to do is to find the number of properties on each city in the address, here
is my code:
var query = _contex.Property.Include(a => a.Address)
.Where (s => s.Status == "Occupied")
group p by p.Address.City into n
select new ViewModel
Count = n.Count()
All looks good, but one thing, if there is no property with this status for a city, the city will NOT appear in the result. What I need is, in this situation, something like City: Seattle Count: 0. I kind of understand I need to use OUTER Join, just need
help in this situation.
I googled a while, but not found anything that helps, can you guys help or point me to some resource.
Thanks and really appreciate.
Feb 04, 2020 10:00 AM|suresh dasari|LINK
Check following articles to use left outer join with group by aggregation
Feb 05, 2020 07:22 PM|byuan|LINK
Thanks. I have tried a few things, but I will try it again with these references.