public PaginatedResult <TSelect> LimitedSearch <TGroup, TSelect>( IDataFilter <TDataModel> filter, IDataLimiter <TDataModel> limiter, IDataProjection <TDataModel, TGroup, TSelect> projection) { Checker.NotNullArgument(filter, nameof(filter)); Checker.NotNullArgument(limiter, nameof(limiter)); Checker.NotNullArgument(projection, nameof(projection)); Checker.NotNullObject(projection.Group, $"{nameof(projection)}.{nameof(projection.Group)}"); Checker.NotNullObject(projection.Select, $"{nameof(projection)}.{nameof(projection.Select)}"); var query = QuerySearch(_query, filter, projection); // A projeção já foi aplicada em QuerySearch(), // por isso não precisa ser repassada aqui var(offset, limit, total, result) = QueryPreLimitResult(query, limiter, null); return(new PaginatedResult <TSelect>( result.GroupBy(projection.Group).Select(projection.Select).ToList(), offset, limit, total )); }
public IEnumerable <TSelect> GetAll <TSelect>(IDataProjection <TDataModel, TSelect> projection) { Checker.NotNullArgument(projection, nameof(projection)); Checker.NotNullObject(projection.Select, () => projection.Select); return(TryApplyIncludes(Query, projection).Select(projection.Select).ToList()); }
public TSelect GetFirst <TSelect>(IDataFilter <TDataModel> filter, IDataProjection <TDataModel, TSelect> projection) { Checker.NotNullArgument(projection, nameof(projection)); Checker.NotNullObject(projection.Select, () => projection.Select); return(QuerySearch(_query, filter, projection).Select(projection.Select).FirstOrDefault()); }
public IEnumerable <TSelect> Search <TSelect>(IDataFilter <TDataModel> filter, IDataProjection <TDataModel, TSelect> projection) { Checker.NotNullArgument(filter, nameof(filter)); Checker.NotNullArgument(projection, nameof(projection)); Checker.NotNullObject(projection.Select, $"{nameof(projection)}.{nameof(projection.Select)}"); return(QuerySearch(Query, filter, projection) .Select(projection.Select).ToList()); }
public IEnumerable <TSelect> GetAll <TGroup, TSelect>( IDataProjection <TDataModel, TGroup, TSelect> projection) { Checker.NotNullArgument(projection, nameof(projection)); Checker.NotNullObject(projection.Group, $"{nameof(projection)}.{nameof(projection.Group)}"); Checker.NotNullObject(projection.Select, $"{nameof(projection)}.{nameof(projection.Select)}"); return(TryApplyIncludes(_query, projection) .GroupBy(projection.Group) .Select(projection.Select) .ToList()); }
public TSelect Find <TSelect>(object[] identifiers, IDataProjection <TDataModel, TSelect> projection) { Checker.NotNullArgument(identifiers, nameof(identifiers)); Checker.NotNullArgument(projection, nameof(projection)); Checker.NotNullObject(projection.Select, $"{nameof(projection)}.{nameof(projection.Select)}"); var entityType = Context.Model.FindEntityType(typeof(TDataModel)); return(QueryFind(entityType, Query, identifiers, projection) .Select(projection.Select) .FirstOrDefault()); }
public PaginatedResult <TSelect> LimitedGet <TSelect>(IDataLimiter <TDataModel> limiter, IDataProjection <TDataModel, TSelect> projection) { Checker.NotNullArgument(limiter, nameof(limiter)); Checker.NotNullArgument(projection, nameof(projection)); Checker.NotNullObject(projection.Select, $"{nameof(projection)}.{nameof(projection.Select)}"); var(offset, limit, total, result) = QueryPreLimitResult(_query, limiter, projection); return(new PaginatedResult <TSelect>( result.Select(projection.Select).ToList(), offset, limit, total )); }
public TSelect Find <TSelect>(TDataModel data, IDataProjection <TDataModel, TSelect> projection) { throw new DataLayerException( $"{this.GetType().Name} not implement {nameof(Find)}(data)!"); }
public TSelect Find <TSelect>(object[] identifiers, IDataProjection <TDataModel, TSelect> projection) { throw new DataLayerException( $"{this.GetType().Name} not implement {nameof(Find)}(identifiers)!"); }
/// <summary> /// Find an item stored by identifier /// </summary> /// <param name="storage">Storage object</param> /// <param name="identifier">Item identifier</param> /// <param name="projection">Data projection</param> /// <returns>Instance of <typeparamref name="TSelect"/>, or null when not found</returns> public static TSelect Find <TDataModel, TSelect>(this IFindableStorageWithSelector <TDataModel> storage, object identifier, IDataProjection <TDataModel, TSelect> projection) where TDataModel : IIdentifiable { Checker.NotNullArgument(storage, nameof(storage)); Checker.NotNullArgument(identifier, nameof(identifier)); Checker.NotNullArgument(projection, nameof(projection)); return(storage.Find(new object[] { identifier }, projection)); }
/// <summary> /// Find an item stored by a data instance /// </summary> /// <param name="storage">Storage object</param> /// <param name="data">Data item</param> /// <param name="projection">Data projection</param> /// <returns>Instance of <typeparamref name="TSelect"/>, or null when not found</returns> public static TSelect Find <TDataModel, TSelect>(this IFindableStorageWithSelector <TDataModel> storage, TDataModel data, IDataProjection <TDataModel, TSelect> projection) where TDataModel : IIdentifiable { Checker.NotNullArgument(storage, nameof(storage)); Checker.NotNullArgument(data, nameof(data)); Checker.NotNullArgument(projection, nameof(projection)); return(storage.Find(data.Identifiers, projection)); }