// Starts 'chaining' load of customers, orders, orderdetails. private void LoadCustomers(string name = null) { Customers.Clear(); // Either get all customers or filter by name. if (string.IsNullOrEmpty(name)) { context.Load(context.GetCustomersQuery(), GetCustomersQueryCallback, true); } else { context.Load(context.FindCustomersQuery(name), GetCustomersQueryCallback, true); } }
/// <summary> /// Gets order statistics. Asynch call. /// </summary> /// <param name="callback">Callback function.</param> /// <param name="year"></param> public void GetOrderStatistics(Action <List <OrderStatistics> > callback, int year) { var context = new ActionDomainContext(); _orders = context.Orders; _callback = callback; context.Load(context.GetOrdersByYearQuery(year), GetOrdersByYearCallback, true); }
/// <summary> /// Constructor of Customer ViewModel /// </summary> public CustomerViewModel() { if (DesignerProperties.IsInDesignTool) { return; } // init commands. _addCommand = new RelayCommand(OnAdd); _editCommand = new RelayCommand(OnEdit); _deleteCommand = new RelayCommand(OnDelete); _saveCommand = new RelayCommand(OnSave); _cancelCommand = new RelayCommand(OnCancel); UpdateState(false); RaiseEvent(Loading); // Load customers from database context = new ActionDomainContext(); Customers = context.Customers; // important. context.Load(context.GetCustomersQuery(), GetCustomersQueryCallback, true); }