using System; using System.Linq; using System.Linq.Expressions; using System.Collections.Generic; using System.Collections.ObjectModel; using DevExpress.Mvvm; using DevExpress.Mvvm.POCO; using DevExpress.DevAV.Common.Utils; using DevExpress.DevAV.DevAVDbDataModel; using DevExpress.Mvvm.DataModel; using DevExpress.DevAV; using DevExpress.DevAV.Common.ViewModel; using DevExpress.Mvvm.ViewModel; namespace DevExpress.DevAV.ViewModels { /// /// Represents the single Customer object view model. /// public partial class CustomerViewModel : SingleObjectViewModel { /// /// Creates a new instance of CustomerViewModel as a POCO view model. /// /// A factory used to create a unit of work instance. public static CustomerViewModel Create(IUnitOfWorkFactory unitOfWorkFactory = null) { return ViewModelSource.Create(() => new CustomerViewModel(unitOfWorkFactory)); } /// /// Initializes a new instance of the CustomerViewModel class. /// This constructor is declared protected to avoid undesired instantiation of the CustomerViewModel type without the POCO proxy factory. /// /// A factory used to create a unit of work instance. protected CustomerViewModel(IUnitOfWorkFactory unitOfWorkFactory = null) : base(unitOfWorkFactory ?? UnitOfWorkSource.GetUnitOfWorkFactory(), x => x.Customers, x => x.Name) { } /// /// The view model for the CustomerEmployees detail collection. /// public CollectionViewModelBase CustomerEmployeesDetails { get { return GetDetailsCollectionViewModel((CustomerViewModel x) => x.CustomerEmployeesDetails, x => x.CustomerEmployees, x => x.CustomerId, (x, key) => x.CustomerId = key); } } /// /// The view model for the CustomerOrders detail collection. /// public CollectionViewModelBase CustomerOrdersDetails { get { return GetDetailsCollectionViewModel((CustomerViewModel x) => x.CustomerOrdersDetails, x => x.Orders, x => x.CustomerId, (x, key) => x.CustomerId = key, query => query.ActualOrders()); } } /// /// The view model for the CustomerQuotes detail collection. /// public CollectionViewModelBase CustomerQuotesDetails { get { return GetDetailsCollectionViewModel((CustomerViewModel x) => x.CustomerQuotesDetails, x => x.Quotes, x => x.CustomerId, (x, key) => x.CustomerId = key, query => query.ActualQuotes()); } } /// /// The view model for the CustomerCustomerStores detail collection. /// public CollectionViewModelBase CustomerCustomerStoresDetails { get { return GetDetailsCollectionViewModel((CustomerViewModel x) => x.CustomerCustomerStoresDetails, x => x.CustomerStores, x => x.CustomerId, (x, key) => x.CustomerId = key); } } } }