Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var producten = (from p in Premy.All()
- join pr in Producten.All() on p.dekking equals pr.ID
- where p.kilometragemax >= 10000 &&
- p.CCmin < 3000 &&
- p.CCmax >= 3000 &&
- p.leeftijdmax >= DateTime.Today.Subtract(car.datumEersteToelating).TotalDays / 365
- group p by new { pr.ID, pr.Naam, pr.ShortDesc, pr.LongDesc } into d
- select new
- {
- ID = d.Key.ID,
- Dekking = d.Key.Naam,
- ShortDesc = d.Key.ShortDesc,
- LongDesc = d.Key.LongDesc,
- PrijsAlgemeen = d.Min(x => x.premie),
- PrijsAlgemeenMaand = d.Min(x => x.premie),
- PrijsMerkdealerMaand = d.Min(x => x.premie),
- PrijsMerkdealer = d.Min(x => x.premie)
- }).ToList();
- List<QuotePremies> producten = (from p in Premy.All()
- join pr in Producten.All() on p.dekking equals pr.ID
- where p.kilometragemax >= 10000 &&
- p.CCmin < 3000 &&
- p.CCmax >= 3000 &&
- p.leeftijdmax >= DateTime.Today.Subtract(car.datumEersteToelating).TotalDays / 365
- group p by new { pr.ID, pr.Naam, pr.ShortDesc, pr.LongDesc } into d
- select new QuotePremies
- {
- ID = d.Key.ID,
- Dekking = d.Key.Naam,
- ShortDesc = d.Key.ShortDesc,
- LongDesc = d.Key.LongDesc,
- PrijsAlgemeen = d.Min(x => x.premie),
- PrijsAlgemeenMaand = d.Min(x => x.premie),
- PrijsMerkdealerMaand = d.Min(x => x.premie),
- PrijsMerkdealer = d.Min(x => x.premie)
- }).ToList();
- public class QuotePremies
- {
- public byte ID { get; set; }
- public string Dekking { get; set; }
- public string ShortDesc { get; set; }
- public string LongDesc { get; set; }
- public decimal PrijsAlgemeen { get; set; }
- public decimal PrijsAlgemeenMaand { get; set; }
- public decimal PrijsMerkdealer { get; set; }
- public decimal PrijsMerkdealerMaand { get; set; }
- }
- PrijsAlgemeen = Convert.ToDecimal(d.Min(x => x.premie))
- public static class Extensions
- {
- // extends IEnumerable to allow conversion to a custom type
- public static TCollection ToMyCustomCollection<TCollection, T>(this IEnumerable<T> ienum)
- where TCollection : IList<T>, new()
- {
- // create our new custom type to populate and return
- TCollection collection = new TCollection();
- // iterate over the enumeration
- foreach (var item in ienum)
- {
- // add to our collection
- collection.Add((T)item);
- }
- return collection;
- }
- }
Add Comment
Please, Sign In to add comment