Is there way to use Distinct in LINQ query syntax?

前端 未结 6 2049
余生分开走
余生分开走 2021-01-01 08:10

Is there way to rewrite:

var tbl = ds.TABLES;
var q = from c in tbl
        select c.TABLE_TYPE;
string s = \"\";
foreach (var item in q.Distinct())
{
    s          


        
6条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 08:43

    The Distinct extension method in LINQ does not have a query syntax equivalent.

    See https://docs.microsoft.com/en-us/archive/blogs/charlie/linq-farm-using-distinct-and-avoiding-lambdas for additional information as to why.

提交回复
热议问题