Example #1
0
 public override int BatchInsert(System.Collections.Generic.IList <System.Collections.Generic.IDictionary <string, object> > data, string tableName)
 {
     if (!data.IsNullOrEmpty())
     {
         DataTable table = new DataTable()
         {
             TableName = tableName
         };
         foreach (var key in data[0].Keys)
         {
             DataColumn idColumn = new DataColumn(key, data[0][key].GetType());
             table.Columns.Add(idColumn);
         }
         int    i   = 0;
         object obj = null;
         foreach (var d in data)
         {
             DataRow dataRow = table.NewRow();
             i = 0;
             foreach (var key in d.Keys)
             {
                 obj = d[key];
                 if (obj == null)
                 {
                     obj = DBNull.Value;
                 }
                 dataRow[i++] = obj;
             }
             table.Rows.Add(dataRow);
         }
         return(BatchInsert(table));
     }
     return(0);
 }