List多个字段标识过滤

class Program
{
   public static void Main(string[] args)
  {get

    List<T> list = new List<T>();
    list.Add(new T() { orderid = 1, houseid = 1 });
    list.Add(new T() { orderid = 1, houseid = 1 });
    list.Add(new T() { orderid = 1, houseid = 2 });
    list.Add(new T() { orderid = 1, houseid =3 });
    list.Add(new T() { orderid = 2, houseid = 1 });
    list.Add(new T() { orderid = 2, houseid = 2 });
    list.Add(new T() { orderid = 2, houseid = 2 });
    list.Add(new T() { orderid = 2, houseid = 3 });string

    var _list= list.Where((x, y) => list.FindIndex(a => a.orderid == x.orderid&&a.houseid==x.houseid) == y); class

  }
  public class T {
    public long orderid { get; set; }
    public long houseid { get; set; }
  }
}List

 

_list 结果以下:static

 

new T() { orderid = 1, houseid = 1 }
new T() { orderid = 1, houseid = 2 }
new T() { orderid = 1, houseid = 3 }
new T() { orderid = 2, houseid = 1 }
new T() { orderid = 2, houseid = 2 }
new T() { orderid = 2, houseid = 3 }new

相关文章
相关标签/搜索