开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜