Guest User

Untitled

a guest
May 17th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. var producten = (from p in Premy.All()
  2. join pr in Producten.All() on p.dekking equals pr.ID
  3. where p.kilometragemax >= 10000 &&
  4. p.CCmin < 3000 &&
  5. p.CCmax >= 3000 &&
  6. p.leeftijdmax >= DateTime.Today.Subtract(car.datumEersteToelating).TotalDays / 365
  7. group p by new { pr.ID, pr.Naam, pr.ShortDesc, pr.LongDesc } into d
  8. select new
  9. {
  10. ID = d.Key.ID,
  11. Dekking = d.Key.Naam,
  12. ShortDesc = d.Key.ShortDesc,
  13. LongDesc = d.Key.LongDesc,
  14. PrijsAlgemeen = d.Min(x => x.premie),
  15. PrijsAlgemeenMaand = d.Min(x => x.premie),
  16. PrijsMerkdealerMaand = d.Min(x => x.premie),
  17. PrijsMerkdealer = d.Min(x => x.premie)
  18. }).ToList();
  19.  
  20. List<QuotePremies> producten = (from p in Premy.All()
  21. join pr in Producten.All() on p.dekking equals pr.ID
  22. where p.kilometragemax >= 10000 &&
  23. p.CCmin < 3000 &&
  24. p.CCmax >= 3000 &&
  25. p.leeftijdmax >= DateTime.Today.Subtract(car.datumEersteToelating).TotalDays / 365
  26. group p by new { pr.ID, pr.Naam, pr.ShortDesc, pr.LongDesc } into d
  27. select new QuotePremies
  28. {
  29. ID = d.Key.ID,
  30. Dekking = d.Key.Naam,
  31. ShortDesc = d.Key.ShortDesc,
  32. LongDesc = d.Key.LongDesc,
  33. PrijsAlgemeen = d.Min(x => x.premie),
  34. PrijsAlgemeenMaand = d.Min(x => x.premie),
  35. PrijsMerkdealerMaand = d.Min(x => x.premie),
  36. PrijsMerkdealer = d.Min(x => x.premie)
  37. }).ToList();
  38.  
  39. public class QuotePremies
  40. {
  41. public byte ID { get; set; }
  42. public string Dekking { get; set; }
  43. public string ShortDesc { get; set; }
  44.  
  45. public string LongDesc { get; set; }
  46. public decimal PrijsAlgemeen { get; set; }
  47. public decimal PrijsAlgemeenMaand { get; set; }
  48. public decimal PrijsMerkdealer { get; set; }
  49. public decimal PrijsMerkdealerMaand { get; set; }
  50. }
  51.  
  52. PrijsAlgemeen = Convert.ToDecimal(d.Min(x => x.premie))
  53.  
  54. public static class Extensions
  55. {
  56. // extends IEnumerable to allow conversion to a custom type
  57. public static TCollection ToMyCustomCollection<TCollection, T>(this IEnumerable<T> ienum)
  58. where TCollection : IList<T>, new()
  59. {
  60. // create our new custom type to populate and return
  61. TCollection collection = new TCollection();
  62.  
  63. // iterate over the enumeration
  64. foreach (var item in ienum)
  65. {
  66. // add to our collection
  67. collection.Add((T)item);
  68. }
  69.  
  70. return collection;
  71. }
  72. }
Add Comment
Please, Sign In to add comment