Returning a Distinct IQueryable with LINQ?

后端 未结 7 1693
無奈伤痛
無奈伤痛 2020-12-29 09:29

I\'m writing a Function that pulls Records from a DataBase using LINQ to get an IQueryable. This LINQ statement will pull all of the records for Active users within a certai

7条回答
  •  感情败类
    2020-12-29 10:25

    Use the Distinct() method to do this. Eg:

    var query = from Notification in db.Notifications
    
                            select Notification.client ;
                query=query.Distinct();
    

    The resulting query will only contain distinct values.

提交回复
热议问题