What is the syntax for an inner join in LINQ to SQL?

后端 未结 19 1898
感情败类
感情败类 2020-11-22 04:25

I\'m writing a LINQ to SQL statement, and I\'m after the standard syntax for a normal inner join with an ON clause in C#.

How do you represent the follo

19条回答
  •  甜味超标
    2020-11-22 05:07

    var list = (from u in db.Users join c in db.Customers on u.CustomerId equals c.CustomerId where u.Username == username
       select new {u.UserId, u.CustomerId, u.ClientId, u.RoleId, u.Username, u.Email, u.Password, u.Salt, u.Hint1, u.Hint2, u.Hint3, u.Locked, u.Active,c.ProfilePic}).First();
    

    Write table names you want, and initialize the select to get the result of fields.

提交回复
热议问题