Best way for retrieving single record results in LINQ to SQL

后端 未结 6 1338
清酒与你
清酒与你 2021-02-01 13:09

If I query a table with a condition on the key field as in:

        var user = from u in dc.Users
                   where u.UserName == usn
                   s         


        
6条回答
  •  难免孤独
    2021-02-01 14:01

    Another option is to use Contains(username) as opposed to "=="

    var user = (from u in dc.UserInfo 
                          where u.Users.Contains(username) 
                          select u).SingleOrDefault();
    

提交回复
热议问题