Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have 3 Tables:

**Region**:
ID,
Name

**District**
ID,
RegionID,
Name

**City**
ID,
DistrictID,
Name


When I write like this:

C#
var result = (from item in db.Region.Include("District.City") select item).ToList();


In result I have objects Dependent on each other

for example: In Region I have 2 Objects, In District 4 objects and In City 8 Objects

I want to write this with Linq Join not with include
can you help me??
Posted

1 solution

Can you use an inner join, something like:
C#
var result = from region in db.Region
             join district in db.District on district.RegionID equals region.ID
             join city in db.City on city.DistrictID equals district.DistrictID
             select ...
 
Share this answer
 

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