fork download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. public class Test
  6. {
  7. class Product
  8. {
  9. public Product()
  10. {
  11.  
  12. }
  13.  
  14. public int RoleId { get; set; }
  15. public int ObjectId { get; set; }
  16. public bool Read { get; set; }
  17.  
  18. public override bool Equals(object obj)
  19. {
  20. return Equals((Product) obj);
  21. }
  22.  
  23. public bool Equals(Product other)
  24. {
  25. return ObjectId == other.ObjectId && Read == other.Read;
  26. }
  27.  
  28. }
  29.  
  30. public static void Main()
  31. {
  32. List<Product> products = new List<Product>()
  33. {
  34. new Product { RoleId = 1, ObjectId = 2, Read = false },
  35. new Product { RoleId = 2, ObjectId = 1, Read = false },
  36. new Product { RoleId = 1, ObjectId = 1, Read = true }
  37. };
  38.  
  39. var groupedCustomerList = products.GroupBy(u => u.RoleId)
  40. .Select(grp => grp.ToList()).ToList();
  41.  
  42. var firstGroup = groupedCustomerList.ElementAt(0);
  43.  
  44. List<Product> productsListSearch = new List<Product>()
  45. {
  46. new Product {ObjectId = 2, Read = false }
  47. , new Product {ObjectId = 1, Read = true }
  48. };
  49.  
  50. var result= productsListSearch.SequenceEqual(firstGroup);
  51. Console.WriteLine(result);
  52. }
  53. }
Success #stdin #stdout 0.05s 35016KB
stdin
Standard input is empty
stdout
True