Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm implementing an asp.net core project. I wrote a linq query like below, however it returns null:
If I omit the last two join, my query works correctly and it returns 1000 elements.My problem is how to join these 4 tables in order to work correctly. I appreciate if anyone helps me.

What I have tried:

var apiapp = (from a in _context.Apiapp
join b in _context.Api on a.Apiid equals b.Id

join c in _context.App on a.AppId equals c.Id

join d in _context.Item on a.ItemId equals d.Id
where a.IsDeleted.Equals(false)
select new { ID = a.Id, Status = a.Status, mDate = a.mDate, name=c.name, item=d.item}).ToList();
Posted
Comments
CHill60 7-Apr-20 8:54am    
If
var apiapp = (from a in _context.Apiapp
join b in _context.Api on a.Apiid equals b.Id
returns 1000 elements but
var apiapp = (from a in _context.Apiapp
join b in _context.Api on a.Apiid equals b.Id 
join c in _context.App on a.AppId equals c.Id 
returns none, then you have nothing in c where Id matches any AppId in a
Sample data is always a good idea
[no name] 7-Apr-20 12:27pm    
Then do 2 at a time; same difference.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900