Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. var query = from person in people
  2. where person.Age == person.GetHashCode()
  3. select person;
  4.  
  5. let foo = item.Property.SomeNullableType
  6.  
  7. let foo = item.Property != null ? item.Property.SomeNullableType : null
  8.  
  9. //this is ok
  10. var results = db.Orders
  11. .GroupBy( o => o.CustomerID )
  12. .Select(g => new
  13. {
  14. CustomerId = g.Key,
  15. OrderCount = g.Count()
  16. });
  17.  
  18. //this could be a lot of round trips.
  19. var results = db.Orders
  20. .GroupBy( o => o.CustomerID )
  21. .Select(g => new
  22. {
  23. CustomerId = g.Key,
  24. OrderIds = g.Select(o => o.OrderId)
  25. });
  26.  
  27. // this is ok
  28. // used ToList to separate linqtosql work from linqtoObject work
  29. var results = db.Orders
  30. .Select(o => new {o.CustomerId, o.OrderId})
  31. .ToList()
  32. .GroupBy(o => o.CustomerId)
  33. .Select(g => new
  34. {
  35. CustomerId = g.Key,
  36. OrderIds = g.Select(o => o.OrderId)
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement