public Form1()
 {
     InitializeComponent();
     using (NwindDbContext context = new NwindDbContext()) {
         Products        = context.Products.ToList();
         FilterViewModel = new FilterViewModel(context);
     }
 }
Exemple #2
0
        public FilterViewModel(NwindDbContext context)
        {
            Categories = context.Categories.ToList();

            UnitPriceMinValue = context.Products.Min(p => p.UnitPrice).Value;
            UnitPriceMaxValue = context.Products.Max(p => p.UnitPrice).Value;

            UnitsInStockMinValue = context.Products.Min(p => p.UnitsInStock).Value;
            UnitsInStockMaxValue = context.Products.Max(p => p.UnitsInStock).Value;

            UnitsOnOrderMinValue = context.Products.Min(p => p.UnitsOnOrder).Value;
            UnitsOnOrderMaxValue = context.Products.Max(p => p.UnitsOnOrder).Value;
        }