Exemple #1
0
        protected int InsertMany(IEnumerable items, ISchema schema, IDataInsertOptions options = null)
        {
            //确认是否可以执行该操作
            this.EnsureInsert(options);

            if (items == null)
            {
                return(0);
            }

            //构建数据操作的选项对象
            if (options == null)
            {
                options = new DataInsertOptions();
            }

            //进行授权验证
            this.Authorize(DataServiceMethod.InsertMany(), options);

            //将当前插入数据集合对象转换成数据字典集合
            var dictionares = DataDictionary.GetDictionaries <TModel>(items);

            //修正数据模式对象
            schema = this.Schematic(schema, Common.TypeExtension.GetElementType(items.GetType()));

            foreach (var dictionary in dictionares)
            {
                //验证待新增的数据
                this.OnValidate(DataServiceMethod.InsertMany(), schema, dictionary, options);
            }

            return(this.OnInsertMany(dictionares, schema, options));
        }
Exemple #2
0
        protected int Insert(object data, ISchema schema, IDataInsertOptions options = null)
        {
            //确认是否可以执行该操作
            this.EnsureInsert(options);

            if (data == null)
            {
                return(0);
            }

            //构建数据操作的选项对象
            if (options == null)
            {
                options = new DataInsertOptions();
            }

            //进行授权验证
            this.Authorize(DataServiceMethod.Insert(), options);

            //将当前插入数据对象转换成数据字典
            var dictionary = DataDictionary.GetDictionary <TModel>(data);

            //修正数据模式对象
            schema = this.Schematic(schema, data.GetType());

            //验证待新增的数据
            this.OnValidate(DataServiceMethod.Insert(), schema, dictionary, options);

            return(this.OnInsert(dictionary, schema, options));
        }