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)); }
private static IEnumerable <IDataDictionary <T> > GetDataDictionaries <T>(this IDataMutateContextBase context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.Count < 1) { return(Array.Empty <IDataDictionary <T> >()); } if (context.IsMultiple) { return(DataDictionary.GetDictionaries <T>((System.Collections.IEnumerable)context.Data)); } return(new IDataDictionary <T>[] { DataDictionary.GetDictionary <T>(context.Data) }); }