/// <summary> /// Execute add data /// </summary> /// <param name="data">Data</param> /// <returns>Return add command</returns> protected override ICommand ExecuteAdd(TEntity data) { var cmd = RdbCommand.CreateNewCommand <TEntity>(OperateType.Insert, data.GetCommandParameters()); SetCommand(cmd, data.GetAllValues()); cmd.MustReturnValueOnSuccess = true; return(cmd); }
/// <summary> /// Execute delete by condition /// </summary> /// <param name="query">Query object</param> /// <returns>Return delete command</returns> protected override ICommand ExecuteDeleteByCondition(IQuery query) { var cmd = RdbCommand.CreateNewCommand <TEntity>(OperateType.Delete); SetCommand(cmd, null); cmd.MustReturnValueOnSuccess = query?.MustReturnValueOnSuccess ?? false; cmd.Query = query; return(cmd); }
/// <summary> /// Execute query data /// </summary> /// <param name="query">Query object</param> /// <returns>Return data</returns> protected override async Task <TEntity> ExecuteGetAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <TEntity>(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; TEntity data = await WorkManager.QuerySingleAsync <TEntity>(cmd).ConfigureAwait(false); return(data); }
/// <summary> /// Execute query data list /// </summary> /// <param name="query">Query object</param> /// <returns>Return data list</returns> protected override async Task <List <TEntity> > ExecuteGetListAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <TEntity>(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; var dataList = (await WorkManager.QueryAsync <TEntity>(cmd).ConfigureAwait(false)).ToList(); return(dataList); }
/// <summary> /// query data list /// </summary> /// <param name="query">query object</param> /// <returns>data list</returns> async Task <List <T> > QueryListAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <T>(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; var objList = (await WorkFactory.QueryAsync <T>(cmd).ConfigureAwait(false)).ToList(); return(objList); }
/// <summary> /// Execute query data paging /// </summary> /// <param name="query">Query object</param> /// <returns>Return data paging</returns> protected override async Task <PagingInfo <TEntity> > ExecuteGetPagingAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <TEntity>(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; var dataPaging = await WorkManager.QueryPagingAsync <TEntity>(cmd).ConfigureAwait(false); return(dataPaging); }
/// <summary> /// add data /// </summary> /// <param name="obj">object</param> /// <returns>icommand</returns> public virtual async Task <ICommand> AddAsync(T obj) { InitVersionFieldValue(obj); //init version field value InitRefreshDateFieldValue(obj); //init refresh date value var cmd = RdbCommand.CreateNewCommand <T>(OperateType.Insert, obj); SetCommand(cmd, obj.GetAllPropertyValues()); cmd.MustReturnValueOnSuccess = true; return(await Task.FromResult(cmd).ConfigureAwait(false)); }
/// <summary> /// query data /// </summary> /// <param name="query">query object</param> /// <returns>data</returns> public virtual async Task <T> GetAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <T>(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; T obj = await WorkFactory.QuerySingleAsync <T>(cmd).ConfigureAwait(false); return(obj); }
/// <summary> /// Execute exists /// </summary> /// <param name="query">Query object</param> /// <returns>Return whether data is exist</returns> protected override async Task <bool> ExecuteExistAsync(IQuery query) { var cmd = RdbCommand.CreateNewCommand <TEntity>(OperateType.Exist); SetCommand(cmd, null); cmd.MustReturnValueOnSuccess = true; cmd.Query = query; cmd.CommandResultType = ExecuteCommandResult.ExecuteScalar; return(await WorkManager.QueryAsync(cmd).ConfigureAwait(false)); }
/// <summary> /// Aggregate function query /// </summary> /// <typeparam name="TValue">Value type</typeparam> /// <param name="query">Query object</param> /// <returns>Return the value</returns> async Task <TValue> AggregateFunctionAsync <TValue>(OperateType funcType, IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <TEntity>(funcType); SetCommand(cmd, null); cmd.Query = query; TValue data = await WorkManager.AggregateValueAsync <TValue>(cmd).ConfigureAwait(false); return(data); }
/// <summary> /// determine whether data is exist /// </summary> /// <param name="query">query object</param> /// <returns>whether data is exist</returns> public virtual async Task <bool> ExistAsync(IQuery query) { var cmd = RdbCommand.CreateNewCommand <T>(OperateType.Exist); SetCommand(cmd, null); cmd.MustReturnValueOnSuccess = true; cmd.Query = query; cmd.CommandResultType = ExecuteCommandResult.ExecuteScalar; return(await WorkFactory.QueryAsync(cmd).ConfigureAwait(false)); }
/// <summary> /// aggregate function query /// </summary> /// <typeparam name="DT">data type</typeparam> /// <param name="query">query object</param> /// <returns>data</returns> async Task <DT> AggregateFunctionAsync <DT>(OperateType funcType, IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <T>(funcType); SetCommand(cmd, null); cmd.Query = query; DT obj = await WorkFactory.QuerySingleAsync <DT>(cmd).ConfigureAwait(false); return(obj); }
/// <summary> /// query data with paging /// </summary> /// <param name="query">query object</param> /// <returns>data paging</returns> public async Task <IPaging <T> > GetPagingAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand <T>(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; var objPaging = await WorkFactory.QueryPagingAsync <T>(cmd).ConfigureAwait(false); return(objPaging); }
/// <summary> /// add data /// </summary> /// <param name="obj">object</param> /// <returns>icommand</returns> public virtual ICommand Add(T obj) { InitVersionFieldValue(obj); //初始化版本值 InitRefreshDateFieldValue(obj); //初始化刷新值 var cmd = RdbCommand.CreateNewCommand(OperateType.Insert, obj); SetCommand(cmd, obj.PropertyValues); cmd.VerifyResult = a => a > 0; cmd.Fields = GetEditFields(); return(cmd); }
/// <summary> /// determine whether data is exist /// </summary> /// <param name="query">query object</param> /// <returns>whether data is exist</returns> public virtual bool Exist(IQuery query) { var cmd = RdbCommand.CreateNewCommand(OperateType.Exist); SetCommand(cmd, null); cmd.VerifyResult = r => r > 0; cmd.Query = query; cmd.Fields = GetQueryFields(); cmd.CommandResultType = ExecuteCommandResult.ExecuteScalar; return(UnitOfWork.UnitOfWork.Query(cmd)); }
/// <summary> /// add data /// </summary> /// <param name="obj">object</param> /// <returns>icommand</returns> public virtual async Task <ICommand> AddAsync(T obj) { InitVersionFieldValue(obj); //初始化版本值 InitRefreshDateFieldValue(obj); //初始化刷新值 var cmd = RdbCommand.CreateNewCommand(OperateType.Insert, obj); SetCommand(cmd, obj.PropertyValues); cmd.VerifyResult = a => a > 0; cmd.Fields = GetEditFields(); return(await Task.FromResult(cmd).ConfigureAwait(false)); }
/// <summary> /// determine whether data is exist /// </summary> /// <param name="query">query object</param> /// <returns>whether data is exist</returns> public virtual async Task <bool> ExistAsync(IQuery query) { var cmd = RdbCommand.CreateNewCommand(OperateType.Exist); SetCommand(cmd, null); cmd.VerifyResult = r => r > 0; cmd.Query = query; cmd.Fields = GetQueryFields(); cmd.CommandResultType = ExecuteCommandResult.ExecuteScalar; return(await UnitOfWork.UnitOfWork.QueryAsync(cmd).ConfigureAwait(false)); }
/// <summary> /// aggregate function query /// </summary> /// <typeparam name="DT">data type</typeparam> /// <param name="query">query object</param> /// <returns>data</returns> async Task <DT> AggregateFunctionAsync <DT>(OperateType funcType, IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(funcType); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); DT obj = await UnitOfWork.UnitOfWork.QuerySingleAsync <DT>(cmd).ConfigureAwait(false); return(obj); }
/// <summary> /// aggregate function query /// </summary> /// <typeparam name="DT">data type</typeparam> /// <param name="query">query object</param> /// <returns>data</returns> DT AggregateFunction <DT>(OperateType funcType, IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(funcType); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); DT obj = UnitOfWork.UnitOfWork.QuerySingle <DT>(cmd); return(obj); }
/// <summary> /// Modify value /// </summary> /// <param name="fields">Fields</param> /// <param name="parameters">Parameters</param> /// <returns>Return modify command</returns> ICommand Update(IEnumerable <string> fields, object parameters, IQuery query) { var cmd = RdbCommand.CreateNewCommand <TEntity>(OperateType.Update); SetCommand(cmd, parameters as Dictionary <string, dynamic>); cmd.Fields = fields; cmd.Parameters = parameters; cmd.MustReturnValueOnSuccess = query?.MustReturnValueOnSuccess ?? false; cmd.Query = query; return(cmd); }
/// <summary> /// query data list /// </summary> /// <param name="query">query object</param> /// <returns>data list</returns> async Task <List <T> > QueryListAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); var objList = (await UnitOfWork.UnitOfWork.QueryAsync <T>(cmd).ConfigureAwait(false)).ToList(); BatchReturnInit(objList, query); return(objList); }
/// <summary> /// query data with paging /// </summary> /// <param name="query">query object</param> /// <returns>data paging</returns> public async Task <IPaging <T> > GetPagingAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); var objPaging = await UnitOfWork.UnitOfWork.QueryPagingAsync <T>(cmd).ConfigureAwait(false); BatchReturnInit(objPaging, query); return(objPaging); }
/// <summary> /// query data /// </summary> /// <param name="query">query object</param> /// <returns>data</returns> public virtual T Get(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); T obj = UnitOfWork.UnitOfWork.QuerySingle <T>(cmd); SingleReturnInit(obj, query); return(obj); }
/// <summary> /// query data list /// </summary> /// <param name="query">query object</param> /// <returns>data list</returns> List <T> QueryList(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); var objList = UnitOfWork.UnitOfWork.Query <T>(cmd).ToList(); BatchReturnInit(objList, query); return(objList); }
/// <summary> /// query data with paging /// </summary> /// <param name="query">query object</param> /// <returns>data paging</returns> public IPaging <T> GetPaging(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); var objPaging = UnitOfWork.UnitOfWork.QueryPaging <T>(cmd); BatchReturnInit(objPaging, query); return(objPaging); }
/// <summary> /// query data /// </summary> /// <param name="query">query object</param> /// <returns>data</returns> public virtual async Task <T> GetAsync(IQuery query) { ICommand cmd = RdbCommand.CreateNewCommand(OperateType.Query); SetCommand(cmd, null); cmd.Query = query; cmd.Fields = GetQueryObjectFields(query); T obj = await UnitOfWork.UnitOfWork.QuerySingleAsync <T>(cmd).ConfigureAwait(false); SingleReturnInit(obj, query); return(obj); }
/// <summary> /// delete data /// </summary> /// <param name="query">delete query</param> /// <returns>ICommand object</returns> public virtual async Task <ICommand> DeleteAsync(IQuery query) { var cmd = RdbCommand.CreateNewCommand <T>(OperateType.Delete); SetCommand(cmd, null); if (query.VerifyResult != null) { cmd.MustReturnValueOnSuccess = query.VerifyResult(0); } cmd.Query = query; return(await Task.FromResult(cmd).ConfigureAwait(false)); }
/// <summary> /// edit value /// </summary> /// <param name="fields">fields</param> /// <param name="parameters">parameters</param> /// <returns></returns> async Task <ICommand> UpdateAsync(IEnumerable <string> fields, object parameters, IQuery query) { var cmd = RdbCommand.CreateNewCommand <T>(OperateType.Update); SetCommand(cmd, parameters as Dictionary <string, dynamic>); cmd.Fields = fields.ToList(); cmd.Parameters = parameters; if (query.VerifyResult != null) { cmd.MustReturnValueOnSuccess = query.VerifyResult(0); } cmd.Query = query; return(await Task.FromResult(cmd)); }
/// <summary> /// delete data /// </summary> /// <param name="query">delete query</param> /// <returns>ICommand object</returns> public virtual async Task <ICommand> DeleteAsync(IQuery query) { var cmd = RdbCommand.CreateNewCommand(OperateType.Delete); SetCommand(cmd, null); if (query.VerifyResult != null) { cmd.VerifyResult = query.VerifyResult; } else { cmd.VerifyResult = r => r >= 0; } cmd.Query = query; return(await Task.FromResult(cmd).ConfigureAwait(false)); }
/// <summary> /// delete data /// </summary> /// <param name="query">delete query</param> /// <returns>ICommand object</returns> public virtual ICommand Delete(IQuery query) { var cmd = RdbCommand.CreateNewCommand(OperateType.Delete); SetCommand(cmd, null); if (query.VerifyResult != null) { cmd.VerifyResult = query.VerifyResult; } else { cmd.VerifyResult = r => r >= 0; } cmd.Query = query; return(cmd); }