Is there way to use Distinct in LINQ query syntax?

前端 未结 6 2073
余生分开走
余生分开走 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:49

    You may capture HashSet and put where clause before select:

    var hs = new HashSet();
    
    from c in "abcabcd"
    where hs.Add(c)
    select c;
    

提交回复
热议问题