Unique list of items using LINQ

后端 未结 6 1530
星月不相逢
星月不相逢 2021-02-01 05:39

I\'ve been using LINQ for a while now, but seem to be stuck on something with regards to Unique items, I have the folling list:

List stock = new Lis         


        
6条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-01 05:44

    You could also do something along these lines, in this case I am taking lucene results then pulling off umbraco nodes to an anonymous type

    var datasource = (from n in SearchResults
    select new
    {
      PageLink = uQuery.GetNode(n.Id).NiceUrl,
      uQuery.GetNode(n.Id).Name,
      Date =    uQuery.GetNode(n.Id).GetProperty("startDate"),
      IntroText = string.IsNullOrEmpty(uQuery.GetNode(n.Id).GetProperty("introText").Value) ? string.Empty : uQuery.GetNode(n.Id).GetProperty("introText").Value,
      Image = ImageCheck(uQuery.GetNode(n.Id).GetProperty("smallImage").Value)
    
    }).Distinct().ToList();
    

提交回复
热议问题