Exemplo n.º 1
0
        /// <summary>
        /// Exist data
        /// </summary>
        /// <param name="query">Query object</param>
        /// <returns>Return whether has data</returns>
        public async Task <bool> ExistAsync(IQuery query)
        {
            var result  = WarehouseManager.Exist <TEntity>(query);
            var isExist = result.IsExist;

            return(await Task.FromResult(isExist).ConfigureAwait(false));;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Query data paging
        /// </summary>
        /// <param name="query">Query object</param>
        /// <returns>Return data paging</returns>
        public async Task <IPaging <TEntity> > GetPagingAsync(IQuery query)
        {
            var paging = Pager.Empty <TEntity>();

            paging = WarehouseManager.MergePaging(paging, query);
            return(await Task.FromResult(paging).ConfigureAwait(false));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Query data list
        /// </summary>
        /// <param name="query">Query model</param>
        /// <returns>Return data list</returns>
        public async Task <List <TEntity> > GetListAsync(IQuery query)
        {
            var datas = await dataAccess.GetListAsync(query).ConfigureAwait(false);

            datas = WarehouseManager.Merge <TEntity>(datas, query);
            return(datas);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Remove data
        /// </summary>
        /// <param name="data">Data</param>
        /// <param name="activationOption">Activation option</param>
        /// <returns>Return the activation record</returns>
        public IActivationRecord Remove(TEntity data, ActivationOption activationOption = null)
        {
            WarehouseManager.Remove(data);
            var identityValue = data.GetIdentityValue();

            return(DefaultActivationRecord <TEntity, TDataAccess> .CreateRemoveObjectRecord(identityValue, activationOption));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Query data list
        /// </summary>
        /// <param name="query">Query object</param>
        /// <returns>Return data list</returns>
        public async Task <List <TEntity> > GetListAsync(IQuery query)
        {
            var datas = new List <TEntity>(0);

            datas = WarehouseManager.Merge(datas, query);
            return(await Task.FromResult(datas).ConfigureAwait(false));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Query data
        /// </summary>
        /// <param name="query">Query object</param>
        /// <returns>Return entity data</returns>
        public async Task <TEntity> GetAsync(IQuery query)
        {
            TEntity data = null;

            data = WarehouseManager.Merge(data, query);
            return(await Task.FromResult(data).ConfigureAwait(false));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Query data paging
        /// </summary>
        /// <param name="query">Query model</param>
        /// <returns>Return data paging</returns>
        public async Task <IPaging <TEntity> > GetPagingAsync(IQuery query)
        {
            var paging = await dataAccess.GetPagingAsync(query).ConfigureAwait(false);

            paging = WarehouseManager.MergePaging(paging, query);
            return(paging);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Query data
        /// </summary>
        /// <param name="query">Query object</param>
        /// <returns>Return data</returns>
        public async Task <TEntity> GetAsync(IQuery query)
        {
            var data = await dataAccess.GetAsync(query).ConfigureAwait(false);

            data = WarehouseManager.Merge(data, query);
            return(data);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Modify
        /// </summary>
        /// <param name="modifyExpression">Modify expression</param>
        /// <param name="query">Query object</param>
        /// <returns>Return the activation record</returns>
        public IActivationRecord Modify(IModify modifyExpression, IQuery query, ActivationOption activationOption = null)
        {
            WarehouseManager.Modify <TEntity>(modifyExpression, query);
            var record = DefaultActivationRecord <TEntity, TDataAccess> .CreateModifyRecord(modifyExpression, query, activationOption);

            return(record);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Remove
        /// </summary>
        /// <param name="query">Query object</param>
        /// <returns>Return the activation record</returns>
        public IActivationRecord Remove(IQuery query, ActivationOption activationOption = null)
        {
            WarehouseManager.Remove <TEntity>(query);
            var record = DefaultActivationRecord <TEntity, TDataAccess> .CreateRemoveByConditionRecord(query, activationOption);

            return(record);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Get sum value
        /// </summary>
        /// <typeparam name="TValue">Value type</typeparam>
        /// <param name="query">Query object</param>
        /// <returns>Return the sum value</returns>
        public async Task <TValue> SumAsync <TValue>(IQuery query)
        {
            var     sumResult = WarehouseManager.Sum <TEntity, TValue>(query);
            dynamic resultVal = sumResult.Value;

            return(await Task.FromResult(resultVal).ConfigureAwait(false));
        }
Exemplo n.º 12
0
 /// <summary>
 /// Get life source
 /// </summary>
 /// <param name="data">Data</param>
 /// <returns>Return the data life source</returns>
 public DataLifeSource GetLifeSource(TEntity data)
 {
     if (data == null)
     {
         return(DataLifeSource.New);
     }
     return(WarehouseManager.GetLifeSource(data));
 }
Exemplo n.º 13
0
        /// <summary>
        /// Get Sum Value
        /// </summary>
        /// <typeparam name="TValue">Value type</typeparam>
        /// <param name="query">Query model</param>
        /// <returns>Return the sum value</returns>
        public async Task <TValue> SumAsync <TValue>(IQuery query)
        {
            var     sumResult = WarehouseManager.Sum <TEntity, TValue>(query);
            dynamic resultVal = sumResult.Value;
            dynamic sumValue  = await dataAccess.SumAsync <TValue>(sumResult.ComputeQuery).ConfigureAwait(false);

            return(sumResult.ValidValue ? resultVal + sumValue : sumValue);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Get min value
        /// </summary>
        /// <typeparam name="TValue">Value type</typeparam>
        /// <param name="query">Query model</param>
        /// <returns>Return the min value</returns>
        public async Task <TValue> MinAsync <TValue>(IQuery query)
        {
            var     minResult = WarehouseManager.Min <TEntity, TValue>(query);
            dynamic resultVal = minResult.Value;
            dynamic minValue  = await dataAccess.MinAsync <TValue>(minResult.ComputeQuery).ConfigureAwait(false);

            return(minResult.ValidValue ? (resultVal < minValue ? resultVal : minValue) : minValue);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Get data count
        /// </summary>
        /// <param name="query">Query object</param>
        /// <returns>Return data count</returns>
        public async Task <long> CountAsync(IQuery query)
        {
            long allCount    = 0;
            var  countResult = WarehouseManager.Count <TEntity>(query);

            allCount = allCount - countResult.PersistentDataCount + countResult.NewDataCount;
            return(await Task.FromResult(allCount).ConfigureAwait(false));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Get data count
        /// </summary>
        /// <param name="query">Query model</param>
        /// <returns>Return data count</returns>
        public async Task <long> CountAsync(IQuery query)
        {
            var allCount = await dataAccess.CountAsync(query).ConfigureAwait(false);

            var countResult = WarehouseManager.Count <TEntity>(query);

            allCount = allCount - countResult.PersistentDataRemoveCount + countResult.NewDataCount;
            return(allCount);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Exist data
        /// </summary>
        /// <param name="query">Query model</param>
        /// <returns>Return whether data is exist</returns>
        public async Task <bool> ExistAsync(IQuery query)
        {
            var result  = WarehouseManager.Exist <TEntity>(query);
            var isExist = result.IsExist;

            if (!isExist)
            {
                isExist = await dataAccess.ExistAsync(result.CheckQuery).ConfigureAwait(false);
            }
            return(isExist);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Get Average Value
        /// </summary>
        /// <typeparam name="TValue">Value type</typeparam>
        /// <param name="query">Query model</param>
        /// <returns>Return the average value</returns>
        public async Task <TValue> AvgAsync <TValue>(IQuery query)
        {
            var countResult = WarehouseManager.Count <TEntity>(query);

            if (countResult.TotalDataCount > 0)
            {
                dynamic sum = await SumAsync <TValue>(query).ConfigureAwait(false);

                var count = await CountAsync(query).ConfigureAwait(false);

                return(sum / count);
            }
            else
            {
                return(await dataAccess.AvgAsync <TValue>(query).ConfigureAwait(false));
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// Modify life status
 /// </summary>
 /// <param name="data">Data</param>
 /// <param name="lifeSource">Life source</param>
 public void ModifyLifeSource(TEntity data, DataLifeSource lifeSource)
 {
     WarehouseManager.ModifyLifeSource(data, lifeSource);
 }