//#region ListAll //public static List<T> ListAll<T>(this IEntityStore<T> store, Expression<Func<T, bool>> conditions, IEnumerable<OrderItem> orderItems) // where T : class //{ // var query = store.Query(conditions); // return query.Order(orderItems).ToList(); //} //public static List<TR> ListAll<T, TR>(this IEntityStore<T> store, Expression<Func<T, bool>> conditions, IEnumerable<OrderItem> orderItems, Func<IQueryable<T>, IQueryable<TR>> selector) // where T : class //{ // if (selector == null) throw new ArgumentNullException("selector"); // var query = store.Query(conditions); // return selector(query.Order(orderItems)).ToList(); //} //#endregion //#region ListPage //public static PageData<T> ListPage<T>(this IEntityStore<T> store, Expression<Func<T, bool>> conditions, IEnumerable<OrderItem> orderItems, int pageIndex, int pageSize) // where T : class //{ // if (orderItems == null) throw new ArgumentNullException(nameof(orderItems)); // if (orderItems.Count() <= 0) throw new ArgumentException(nameof(orderItems), "至少包含一个排序字段"); // if (pageSize <= 0) throw new ArgumentOutOfRangeException("pageSize", "pageSize必须大于0"); // if (pageIndex < 0) throw new ArgumentOutOfRangeException("pageIndex", "pageIndex必须为正数"); // var query = store.Query(conditions); // var sortedQuery = query.Order(orderItems); // return new PageData<T>(sortedQuery, pageIndex, pageSize); //} //public static PageData<TR> ListPage<T, TR>(this IEntityStore<T> store, Expression<Func<T, bool>> conditions, IEnumerable<OrderItem> orderItems, Func<IQueryable<T>, IQueryable<TR>> selector, int pageIndex, int pageSize) // where T : class //{ // if (selector == null) throw new ArgumentNullException("selector"); // if (orderItems == null) throw new ArgumentNullException(nameof(orderItems)); // if (orderItems.Count() <= 0) throw new ArgumentException(nameof(orderItems), "至少包含一个排序字段"); // if (pageSize <= 0) throw new ArgumentOutOfRangeException("pageSize", "pageSize必须大于0"); // if (pageIndex < 0) throw new ArgumentOutOfRangeException("pageIndex", "pageIndex必须为正数"); // var query = store.Query(conditions); // var sortedQuery = selector(query).Order(orderItems); // return new PageData<TR>(sortedQuery, pageIndex, pageSize); //} //#endregion //#region ListLimit //public static LimitData<T> ListLimit<T>(this IEntityStore<T> store, Expression<Func<T, bool>> conditions, IEnumerable<OrderItem> orderItems, int offset, int limit) // where T : class //{ // if (orderItems == null) throw new ArgumentNullException(nameof(orderItems)); // if (orderItems.Count() <= 0) throw new ArgumentException(nameof(orderItems), "至少包含一个排序字段"); // if (limit <= 0) throw new ArgumentOutOfRangeException(nameof(limit), $"{nameof(limit)}必须大于0"); // if (offset < 0) throw new ArgumentOutOfRangeException(nameof(offset), $"{nameof(offset)}必须为正数或零"); // var query = store.Query(conditions); // var sortedQuery = query.Order(orderItems); // return new LimitData<T>(sortedQuery, offset, limit); //} //public static LimitData<TR> ListLimit<T, TR>(this IEntityStore<T> store, Expression<Func<T, bool>> conditions, IEnumerable<OrderItem> orderItems, Func<IQueryable<T>, IQueryable<TR>> selector, int offset, int limit) // where T : class //{ // if (selector == null) throw new ArgumentNullException(nameof(selector)); // if (orderItems == null) throw new ArgumentNullException(nameof(orderItems)); // if (orderItems.Count() <= 0) throw new ArgumentException(nameof(orderItems), "必须有排序字段"); // if (limit <= 0) throw new ArgumentOutOfRangeException(nameof(limit), $"{nameof(limit)}必须大于0"); // if (offset < 0) throw new ArgumentOutOfRangeException(nameof(offset), $"{nameof(offset)}必须为正数或零"); // var query = store.Query(conditions); // var sortedQuery = selector(query).Order(orderItems); // return new LimitData<TR>(sortedQuery, offset, limit); //} //#endregion #region DeleteByCondition public static void Delete <T>(this IEntityStore <T> store, Expression <Func <T, bool> > conditions) where T : class { _ = store ?? throw new ArgumentNullException(nameof(store)); var list = store.Query(conditions).ToList(); store.Delete(list); }
/// <inheritdoc /> public void Delete(EntityId entityId, DeleteBehaviour deleteBehaviour) { if (entityId == null) { throw new ArgumentNullException("entityId"); } entityId = EnsureAbsoluteEntityId(entityId); _entityStore.Delete(entityId, deleteBehaviour); }