Exemple #1
0
 /// <summary>
 /// 单表数据删除
 /// </summary>
 /// <returns>删除条目数</returns>
 public async Task <int> DeleteAsync()
 {
     return(await SqlHelper.ExecuteAsync(
                DC.Conn,
                DC.SqlProvider.GetSQL <M>(UiMethodEnum.DeleteAsync)[0],
                DC.GetParameters()));
 }
Exemple #2
0
 /// <summary>
 /// 单表单值查询
 /// </summary>
 /// <typeparam name="V">int/long/decimal/...</typeparam>
 public async Task <V> QuerySingleValueAsync <V>()
 {
     return(await SqlHelper.ExecuteScalarAsync <V>(
                DC.Conn,
                DC.SqlProvider.GetSQL <M>(UiMethodEnum.QuerySingleValueAsync)[0],
                DC.GetParameters()));
 }
 public async Task <List <VM> > QueryListAsync <VM>(Expression <Func <VM> > func)
 {
     SelectMHandle(func);
     return((await SqlHelper.QueryAsync <VM>(
                 DC.Conn,
                 DC.SqlProvider.GetSQL <VM>(UiMethodEnum.JoinQueryListAsync)[0],
                 DC.GetParameters())).ToList());
 }
 /// <summary>
 /// 单表单条数据查询
 /// </summary>
 /// <typeparam name="VM">ViewModel</typeparam>
 public async Task <VM> QueryFirstOrDefaultAsync <VM>(Expression <Func <VM> > func)
 {
     SelectMHandle(func);
     return(await SqlHelper.QueryFirstOrDefaultAsync <VM>(
                DC.Conn,
                DC.SqlProvider.GetSQL <VM>(UiMethodEnum.JoinQueryFirstOrDefaultAsync)[0],
                DC.GetParameters()));
 }
 /// <summary>
 /// 多表单条数据查询
 /// </summary>
 public async Task <M> QueryFirstOrDefaultAsync <M>()
 {
     SelectMHandle <M>();
     return(await SqlHelper.QueryFirstOrDefaultAsync <M>(
                DC.Conn,
                DC.SqlProvider.GetSQL <M>(UiMethodEnum.JoinQueryFirstOrDefaultAsync)[0],
                DC.GetParameters()));
 }
 /// <summary>
 /// 插入单条数据
 /// </summary>
 /// <returns>插入条目数</returns>
 public async Task <int> CreateAsync(M m)
 {
     DC.GetProperties(m);
     return(await SqlHelper.ExecuteAsync(
                DC.Conn,
                DC.SqlProvider.GetSQL <M>(UiMethodEnum.CreateAsync)[0],
                DC.GetParameters()));
 }
Exemple #7
0
        /// <summary>
        /// 批量插入数据
        /// </summary>
        /// <returns>插入条目数</returns>
        public async Task <int> CreateBatchAsync(IEnumerable <M> mList)
        {
            await DC.GetProperties(mList);

            return(await SqlHelper.ExecuteAsync(
                       DC.Conn,
                       DC.SqlProvider.GetSQL <M>(UiMethodEnum.CreateBatchAsync)[0],
                       DC.GetParameters()));
        }
 /// <summary>
 /// 批量插入数据
 /// </summary>
 /// <returns>插入条目数</returns>
 public async Task <int> CreateBatchAsync(IEnumerable <M> mList)
 {
     return(await DC.BDH.StepProcess(mList, 15, async list =>
     {
         DC.ResetConditions();
         DC.GetProperties(list);
         return await SqlHelper.ExecuteAsync(
             DC.Conn,
             DC.SqlProvider.GetSQL <M>(UiMethodEnum.CreateBatchAsync)[0],
             DC.GetParameters());
     }));
 }
Exemple #9
0
        /// <summary>
        /// 多表分页查询
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页条数</param>
        public async Task <PagingList <M> > QueryPagingListAsync <M>(int pageIndex, int pageSize)
        {
            var result = new PagingList <M>();

            result.PageIndex = pageIndex;
            result.PageSize  = pageSize;
            var paras = DC.GetParameters();
            var sql   = DC.SqlProvider.GetSQL <M>(UiMethodEnum.JoinQueryPagingListAsync, result.PageIndex, result.PageSize);

            result.TotalCount = await SqlHelper.ExecuteScalarAsync <long>(DC.Conn, sql[0], paras);

            result.Data = (await SqlHelper.QueryAsync <M>(DC.Conn, sql[1], paras)).ToList();
            return(result);
        }
        /// <summary>
        /// 单表分页查询
        /// </summary>
        /// <param name="pageIndex">页码</param>
        /// <param name="pageSize">每页条数</param>
        public async Task <PagingList <M> > QueryPagingListAsync <M>(PagingQueryOption option)
        {
            SelectMHandle <M>();
            OrderByOptionHandle(option);
            var result = new PagingList <M>();

            result.PageIndex = option.PageIndex;
            result.PageSize  = option.PageSize;
            var paras = DC.GetParameters();
            var sql   = DC.SqlProvider.GetSQL <M>(UiMethodEnum.JoinQueryPagingListAsync, result.PageIndex, result.PageSize);

            result.TotalCount = await SqlHelper.ExecuteScalarAsync <long>(DC.Conn, sql[0], paras);

            result.Data = (await SqlHelper.QueryAsync <M>(DC.Conn, sql[1], paras)).ToList();
            return(result);
        }
Exemple #11
0
        /// <summary>
        /// 查询是否存在符合条件的数据
        /// </summary>
        public async Task <bool> ExistAsync()
        {
            var count = await SqlHelper.ExecuteScalarAsync <long>(
                DC.Conn,
                DC.SqlProvider.GetSQL <M>(UiMethodEnum.ExistAsync)[0],
                DC.GetParameters());

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }