/// <summary> /// Retrieves the entities matching the provided filter group. /// </summary> /// <param name="group"></param> /// <returns></returns> public virtual T[] Index <T>(IDataFilterGroup group) where T : IEntity { T[] entities = new T[] {}; if (EnablePaging) { entities = Collection <T> .ConvertAll(DataAccess.Data.Indexer.GetPageOfEntities <T>(group, Location, SortExpression)); } else { entities = Collection <T> .ConvertAll(DataAccess.Data.Indexer.GetEntities <T>(group, SortExpression)); } if (RequireAuthorisation) { AuthoriseIndexStrategy.New <T>().EnsureAuthorised(ref entities); } AssignStrategies(entities); React(entities); return(entities); }
/// <summary> /// Retrieves all the entities matching the filter group. /// </summary> /// <param name="group">The group of filters to apply to the query.</param> /// <returns>The entities of the specified type found in the data store.</returns> public override IEntity[] GetEntities(IDataFilterGroup group) { Collection <IEntity> entities = new Collection <IEntity>(); using (LogGroup logGroup = LogGroup.StartDebug("Retrieving entities by type and filter.")) { if (group != null && group.Filters != null && group.Filters.Length > 0) { LogWriter.Debug("Group operator: " + group.Operator.ToString()); Type[] allTypes = group.AllTypes; // Loop through the types and load them foreach (Type type in allTypes) { LogWriter.Debug("Includes type: " + type.ToString()); Db4oDataStore store = (Db4oDataStore)GetDataStore(type); entities.AddRange(store.ObjectContainer.Query <IEntity>(delegate(IEntity entity) { return(group.IsMatch(entity)); })); } foreach (IEntity entity in entities) { using (LogGroup logGroup2 = LogGroup.StartDebug("Entity found.")) { LogWriter.Debug("Entity ID: " + entity.ID); LogWriter.Debug("Entity .ToString(): " + entity.ToString()); } } if (entities.Count == 0) { LogWriter.Debug("No entities retrieved."); } } else { throw new ArgumentException("The provided filter group is empty.", "group"); } } return(Release((IEntity[])entities.ToArray())); }
/// <summary> /// Retrieves the specified page of objects from the provided IObjectSet. /// </summary> /// <param name="type">The type of entities to retrieve.</param> /// <param name="filterGroup">The group to filter the query by.</param> /// <param name="sortExpression">The sort expression to apply before retrieving the page.</param> /// <returns>An array of the objects retrieved.</returns> public override IEntity[] GetEntities(Type type, IDataFilterGroup filterGroup, string sortExpression) { Db4oDataStore store = (Db4oDataStore)GetDataStore(type); Collection <IEntity> list = new Collection <IEntity>(); int i = 0; if (store.DoesExist) { list = new Collection <IEntity>(store.ObjectContainer.Query <IEntity>(delegate(IEntity e) { bool matches = filterGroup.IsMatch(e); i++; return(matches); })); } return(Release((IEntity[])list.ToArray(type))); }
/// <summary> /// Counts the specified page of objects from the provided IObjectSet. /// </summary> /// <param name="type">The type of entities to retrieve.</param> /// <param name="filterGroup">The group to filter the query by.</param> /// <returns>The total number of entities counted.</returns> public override int CountEntities(Type type, IDataFilterGroup filterGroup) { // TODO: Boost performance by looping through an object set without actually loading the entities Db4oDataStore store = (Db4oDataStore)GetDataStore(type); Collection <IEntity> list = new Collection <IEntity>(); int i = 0; if (store.DoesExist) { list = new Collection <IEntity>(store.ObjectContainer.Query <IEntity>(delegate(IEntity e) { bool matches = filterGroup.IsMatch(e); i++; return(matches); })); } return(list.Count); }
/// <summary> /// Retrieves the specified page of objects from the provided IObjectSet. /// </summary> /// <param name="type">The type of entities to retrieve.</param> /// <param name="filterGroup">The group to filter the query by.</param> /// <param name="location">The paging location to filter the query by.</param> /// <param name="sortExpression">The sort expression to apply before retrieving the page.</param> /// <returns>An array of the objects retrieved.</returns> public override IEntity[] GetPageOfEntities(Type type, IDataFilterGroup filterGroup, PagingLocation location, string sortExpression) { Db4oDataStore store = (Db4oDataStore)GetDataStore(type); Collection <IEntity> list = new Collection <IEntity>(); IObjectSet os = null; if (store.DoesExist) { Predicate matches = new MatchFilterGroupPredicate(filterGroup); os = store.ObjectContainer.Query(matches, new DynamicComparer( type, sortExpression)); list.AddRange(GetPage(os, location)); } return(Release((IEntity[])list.ToArray(type))); }
public Type[] GetAllTypes(IDataFilterGroup group) { List <Type> types = new List <Type>(); if (group.Filters != null) { foreach (IDataFilter filter in group.Filters) { if (filter.Types != null) { foreach (Type type in filter.Types) { if (!types.Contains(type)) { types.Add(type); } } } } } if (group.ChildGroups != null) { foreach (IDataFilterGroup childGroup in group.ChildGroups) { foreach (Type type in GetAllTypes(childGroup)) { if (!types.Contains(type)) { types.Add(type); } } } } return(types.ToArray()); }
/// <summary> /// Retrieves the entities matching the provided filter group. /// </summary> /// <param name="group"></param> /// <returns></returns> T[] IIndexStrategy.Index <T>(IDataFilterGroup group) { return(this.Index <T>((FilterGroup)group)); }
public abstract int CountEntities <T>(IDataFilterGroup filterGroup) where T : IEntity;
/// <summary> /// Retrieves the entities matching the provided filter group. /// </summary> /// <param name="group"></param> /// <returns></returns> public virtual IEntity[] Index(IDataFilterGroup group) { return((IEntity[])Reflector.InvokeGenericMethod(this, "Index", new Type[] { EntityState.GetType(TypeName) }, new object[] { group })); }
/// <summary> /// Retrieves the entity matching the provided filter group. /// </summary> /// <param name="group"></param> /// <returns></returns> IEntity IRetrieveStrategy.Retrieve(IDataFilterGroup group) { return(Retrieve((FilterGroup)group)); }
public MatchFilterGroupPredicate(IDataFilterGroup filterGroup) { FilterGroup = filterGroup; }
public abstract int CountEntities(Type type, IDataFilterGroup filterGroup);
public abstract IEntity[] GetEntities(Type type, IDataFilterGroup filterGroup, string sortExpression);
/// <summary> /// Retrieves all the entities of the specified type from the data store. /// </summary> /// <param name="group">The group of filters to apply to the query.</param> /// <returns>The entities of the specified type found in the data store.</returns> public abstract IEntity[] GetEntities(IDataFilterGroup group);
/// <summary> /// Counts all the entities matching the filter group. /// </summary> /// <param name="group">The group of filters to apply to the query.</param> /// <returns>The total number of entities counted.</returns> public override int CountEntities(IDataFilterGroup group) { // TODO: Boost performance by looping through an object set without actually loading the entities Collection <IEntity> entities = new Collection <IEntity>(); using (LogGroup logGroup = LogGroup.StartDebug("Counting entities by type and filter.")) { if (group != null && group.Filters != null && group.Filters.Length > 0) { LogWriter.Debug("Group operator: " + group.Operator.ToString()); List <Type> allTypes = new List <Type>(); foreach (IDataFilter filter in group.Filters) { if (filter.Types != null) { foreach (Type type in filter.Types) { if (!allTypes.Contains(type)) { allTypes.Add(type); } } } } // Loop through the types and load them foreach (Type type in allTypes) { LogWriter.Debug("Includes type: " + type.ToString()); Db4oDataStore store = (Db4oDataStore)GetDataStore(type); entities.AddRange(store.ObjectContainer.Query <IEntity>(delegate(IEntity entity) { return(group.IsMatch(entity)); })); } foreach (IEntity entity in entities) { using (LogGroup logGroup2 = LogGroup.StartDebug("Entity found.")) { //IEntity entity = (IEntity)os.Next(); LogWriter.Debug("Entity ID: " + entity.ID); LogWriter.Debug("Entity .ToString(): " + entity.ToString()); } } if (entities.Count == 0) { LogWriter.Debug("No entities retrieved."); } } else { throw new ArgumentException("The provided filter group is empty.", "group"); } } return(entities.Count); }
public abstract IEntity[] GetPageOfEntities(Type type, IDataFilterGroup filterGroup, PagingLocation location, string sortExpression);
public abstract T[] GetEntities <T>(IDataFilterGroup filterGroup, string sortExpression) where T : IEntity;
/// <summary> /// Counts the specified page of objects from the provided IObjectSet. /// </summary> /// <param name="filterGroup">The group to filter the query by.</param> /// <returns>The total number of entities counted.</returns> public override int CountEntities <T>(IDataFilterGroup filterGroup) { return(CountEntities(typeof(T), filterGroup)); }
/// <summary> /// Retrieves the entity matching the provided filter group. /// </summary> /// <param name="group"></param> /// <returns></returns> T IRetrieveStrategy.Retrieve <T>(IDataFilterGroup group) { return(Retrieve <T>((FilterGroup)group)); }
/// <summary> /// Retrieves the specified page of objects from the provided IObjectSet. /// </summary> /// <param name="filterGroup">The group to filter the query by.</param> /// <param name="location">The paging location to filter the query by.</param> /// <param name="sortExpression">The sort expression to apply before retrieving the page.</param> /// <returns>An array of the objects retrieved.</returns> public override T[] GetPageOfEntities <T>(IDataFilterGroup filterGroup, PagingLocation location, string sortExpression) { return(Collection <T> .ConvertAll(GetPageOfEntities(typeof(T), filterGroup, location, sortExpression))); }
public abstract T[] GetPageOfEntities <T>(IDataFilterGroup filterGroup, PagingLocation location, string sortExpression) where T : IEntity;
public Type[] GetAllTypes(IDataFilterGroup group) { List<Type> types = new List<Type>(); if (group.Filters != null) { foreach (IDataFilter filter in group.Filters) { if (filter.Types != null) { foreach (Type type in filter.Types) { if (!types.Contains(type)) { types.Add(type); } } } } } if (group.ChildGroups != null) { foreach (IDataFilterGroup childGroup in group.ChildGroups) { foreach (Type type in GetAllTypes(childGroup)) { if (!types.Contains(type)) { types.Add(type); } } } } return types.ToArray(); }
/// <summary> /// Counts all the entities of the specified type from the data store. /// </summary> /// <param name="group">The group of filters to apply to the query.</param> /// <returns>The total number of entities found.</returns> public abstract int CountEntities(IDataFilterGroup group);