コード例 #1
0
ファイル: RideStorage.cs プロジェクト: e5r/E5R.Architecture
        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
                       ));
        }
コード例 #2
0
ファイル: FullStorage`2.cs プロジェクト: e5r/E5R.Architecture
        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());
        }
コード例 #3
0
ファイル: RideStorage.cs プロジェクト: e5r/E5R.Architecture
        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());
        }
コード例 #4
0
ファイル: FullStorage`2.cs プロジェクト: e5r/E5R.Architecture
        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());
        }
コード例 #5
0
ファイル: RideStorage.cs プロジェクト: e5r/E5R.Architecture
        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());
        }
コード例 #6
0
ファイル: FullStorage`2.cs プロジェクト: e5r/E5R.Architecture
        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());
        }
コード例 #7
0
ファイル: RideStorage.cs プロジェクト: e5r/E5R.Architecture
        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
                       ));
        }
コード例 #8
0
ファイル: RideStorage.cs プロジェクト: e5r/E5R.Architecture
 public TSelect Find <TSelect>(TDataModel data,
                               IDataProjection <TDataModel, TSelect> projection)
 {
     throw new DataLayerException(
               $"{this.GetType().Name} not implement {nameof(Find)}(data)!");
 }
コード例 #9
0
ファイル: RideStorage.cs プロジェクト: e5r/E5R.Architecture
 public TSelect Find <TSelect>(object[] identifiers,
                               IDataProjection <TDataModel, TSelect> projection)
 {
     throw new DataLayerException(
               $"{this.GetType().Name} not implement {nameof(Find)}(identifiers)!");
 }
コード例 #10
0
        /// <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));
        }
コード例 #11
0
        /// <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));
        }