Get distinct records using linq to entity

后端 未结 5 830
臣服心动
臣服心动 2020-12-16 11:11

Hi I\'m using linq to entity in my application. I need to get distinct records based on one column value \"Name\"

So I have a table similar like you can see below:

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-16 11:54

    Here's another variation I ended up using which was based off the response from Svetlana. Shows an example of populating a GridView control with unique values. Thanks!

            dataGridView_AnalyzeTestSuites.DataSource = (
                from tr in _db.TestResults
                where tr.TaskId == taskId
                select new { TestSuiteName = tr.Test.TestSuite.Name }
                ).Distinct().ToList();
    

提交回复
热议问题