LINQ: Query to get information from 2 tables
I have a PM-Table in which are a SenderID and a ReciID.
Both have a fo开发者_如何转开发reign key construct in the MSSQL Table to table User.
How I can get the Information about SenderID.Username and ReciID.Username?
I know there is this method:
DataLoadOptions options = new DataLoadOptions();
options.LoadWith<Biethistorie>(a => a.Auktion);
options.LoadWith<Auktion>(a => a.Artikel);
dc.LoadOptions = options;
But the problem is, the User-table is very large and I only need the 1 information to display (username).
var query = from emp in dbEmp.Employees
join dept in dbEmp.Departments
on emp.DeptID equals dept.DeptID
select new
{
EmpID = emp.EmpID,
EmpName = emp.EmpName,
Age = emp.Age,
Address = emp.Address,
DeptName = dept.DepartmentName
};
select new{} gives you only the fields that you choose to return.
精彩评论