I am having the scenario with multiple linq include methods with table object associations.
Suppose the scenario is:
User has Groups
User has Permissions
User has Vehicles
var _users=
(from u in dbconetxt.Users
join g in dbconetxt.Gropus on u.userId equals g.userId
join p in dbconetxt.Permissions on u.userId equals p.userId
join v in dbconetxt.Vehicles on u.userId equals v.userId
Where u.Status=true
select u).Include(u.Groups)
.Include(u.Permissions)
.Include(u.Vehicles)
.ToList()
After joining all these tables within a single query, I select the User Object. Certainly, I would get List, but I want each User Object should Include its respective Groups, Permissions, Vehicles, but from Vehicles and Permissions, I want to load only few Columns/Properties, not all. So, how do I specify which Columns to load in this scenario?
I am using Entity Framework 4.1 + C# + SQL Server.
Include is an extension method attached to IQueryable. That means you have to use it on the DbSet Users.
If you want to select only specified columns, you can create an anonymous type or a class with a parameterless constructor.
or