using System; using System.Linq; using System.ComponentModel; using DevExpress.Mvvm; using DevExpress.Mvvm.POCO; using System.Collections.ObjectModel; using DevExpress.DevAV.Common.Utils; using DevExpress.Mvvm.DataModel; namespace DevExpress.DevAV.Common.ViewModel { /// /// Represents a POCO view models used by SingleObjectViewModel to exposing collections of related entities. /// This is a partial class that provides an extension point to add custom properties, commands and override methods without modifying the auto-generated code. /// /// A repository entity type. /// A projection entity type. /// A primary key value type. /// A unit of work type. public class LookUpEntitiesViewModel : EntitiesViewModel, IDocumentContent where TEntity : class where TProjection : class where TUnitOfWork : IUnitOfWork { /// /// Creates a new instance of LookUpEntitiesViewModel as a POCO view model. /// /// A factory used to create a unit of work instance. /// A function that returns a repository representing entities of the given type. /// An optional parameter that provides a LINQ function used to customize a query for entities. The parameter, for example, can be used for sorting data and/or for projecting data to a custom type that does not match the repository entity type. public static LookUpEntitiesViewModel Create( IUnitOfWorkFactory unitOfWorkFactory, Func> getRepositoryFunc, Func, IQueryable> projection = null) { return ViewModelSource.Create(() => new LookUpEntitiesViewModel(unitOfWorkFactory, getRepositoryFunc, projection)); } /// /// Initializes a new instance of the LookUpEntitiesViewModel class. /// This constructor is declared protected to avoid an undesired instantiation of the LookUpEntitiesViewModel type without the POCO proxy factory. /// /// A factory used to create a unit of work instance. /// A function that returns a repository representing entities of the given type. /// A LINQ function used to customize a query for entities. The parameter, for example, can be used for sorting data and/or for projecting data to a custom type that does not match the repository entity type. protected LookUpEntitiesViewModel( IUnitOfWorkFactory unitOfWorkFactory, Func> getRepositoryFunc, Func, IQueryable> projection ) : base(unitOfWorkFactory, getRepositoryFunc, projection) { } protected override IEntitiesChangeTracker CreateEntitiesChangeTracker() { return new EntitiesChangeTracker(this); } } }