// 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> /// 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); }