/// <summary>
        ///     取得列表数据
        /// </summary>
        public ApiPageData <TData> PageData(int page, int limit, string sort, bool desc, string condition,
                                            params DbParameter[] args)
        {
            if (!string.IsNullOrEmpty(BaseQueryCondition))
            {
                if (string.IsNullOrEmpty(condition))
                {
                    condition = BaseQueryCondition;
                }
                else if (condition != BaseQueryCondition && !condition.Contains(BaseQueryCondition))
                {
                    condition = $"({BaseQueryCondition}) AND ({condition})";
                }
            }

            if (!DataExtendChecker.PrepareQuery <TData>(Access, ref condition, ref args))
            {
                return(null);
            }

            var datas = Access.Page(page, limit, sort, desc, condition, args);

            OnListLoaded(datas.Rows);
            return(datas);
        }
        /// <summary>
        ///     删除对象
        /// </summary>
        public async Task <bool> DeleteAsync(TPrimaryKey id)
        {
            if (!DataExtendChecker.PrepareDelete <TData, TPrimaryKey>(new[] { id }))
            {
                return(false);
            }
            using var scope = TransactionScope.CreateScope(Access.DataBase);
            {
                var res = await DeleteAsyncInner(id);

                scope.Succeed();
                return(res);
            }
        }
        /// <summary>
        ///     删除对象
        /// </summary>
        public bool Delete(TPrimaryKey id)
        {
            if (!DataExtendChecker.PrepareDelete <TData, TPrimaryKey>(new[] { id }))
            {
                return(false);
            }

            using var scope = TransactionScope.CreateScope(Access.DataBase);
            {
                if (!DeleteInner(id))
                {
                    return(false);
                }

                scope.Succeed();
            }

            return(true);
        }
        /// <summary>
        ///     新增
        /// </summary>
        public virtual async Task <bool> AddNewAsync(TData data)
        {
            if (!DataExtendChecker.PrepareAddnew(data))
            {
                return(false);
            }

            using var scope = TransactionScope.CreateScope(Access.DataBase);
            {
                if (!CanSave(data, true))
                {
                    return(false);
                }

                if (!PrepareSave(data, true))
                {
                    return(false);
                }

                if (data.__status.IsExist)
                {
                    if (!await Access.UpdateAsync(data))
                    {
                        return(false);
                    }
                }
                else if (!await Access.InsertAsync(data))
                {
                    return(false);
                }

                if (!Saved(data, BusinessCommandType.AddNew))
                {
                    return(false);
                }
                scope.Succeed();
            }

            return(true);
        }
        /// <summary>
        ///     更新对象
        /// </summary>
        public virtual async Task <bool> UpdateAsync(TData data)
        {
            if (Equals(data.Id, default))
            {
                return(await AddNewAsync(data));
            }

            if (!DataExtendChecker.PrepareUpdate(data))
            {
                return(false);
            }

            using var scope = TransactionScope.CreateScope(Access.DataBase);
            {
                if (!CanSave(data, false))
                {
                    return(false);
                }

                if (!PrepareSave(data, false))
                {
                    return(false);
                }

                if (!await Access.UpdateAsync(data))
                {
                    return(false);
                }
                if (!Saved(data, BusinessCommandType.Update))
                {
                    return(false);
                }
                scope.Succeed();
            }

            return(true);
        }
        /// <summary>
        ///     删除对象
        /// </summary>
        public async Task <bool> DeleteAsync(IEnumerable <TPrimaryKey> ids)
        {
            var list = ids.ToArray();

            if (!DataExtendChecker.PrepareDelete <TData, TPrimaryKey>(list))
            {
                return(false);
            }

            using var scope = TransactionScope.CreateScope(Access.DataBase);
            {
                foreach (var id in list)
                {
                    if (!await DeleteAsyncInner(id))
                    {
                        return(false);
                    }
                }

                scope.Succeed();
            }

            return(true);
        }