示例#1
0
        protected int UpsertMany(IEnumerable items, ISchema schema, IDataUpsertOptions options = null)
        {
            //确认是否可以执行该操作
            this.EnsureUpsert(options);

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

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

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

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

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

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

            return(this.OnUpsertMany(dictionares, schema, options));
        }
示例#2
0
        protected int Upsert(object data, ISchema schema, IDataUpsertOptions options = null)
        {
            //确认是否可以执行该操作
            this.EnsureUpsert(options);

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

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

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

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

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

            //验证待复写的数据
            this.OnValidate(DataServiceMethod.Upsert(), schema, dictionary, options);

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