public void xmldata_to_table(db_schema db, string table) { List <schema_field> cols = db.table_fields(table); // cols using (GotDotNet.XPath.XPathReader xr = new GotDotNet.XPath.XPathReader(data_path(table), "/root/data")) { if (xr.ReadUntilMatch()) { while (xr.MoveToNextAttribute()) { schema_field field = findField(cols, xr.Value); if (field == null) { continue; } field.AttrName = xr.Name; } } else { throw new Exception("la struttura xml del file data della tabella '" + table + "' non รจ corretta"); } } // insert rows bool identity = db.type == dbType.sqlserver && cols.FirstOrDefault(x => x.AutoNumber) != null; if (identity) { db.set_identity(table, true); } try { using (GotDotNet.XPath.XPathReader xr = new GotDotNet.XPath.XPathReader(data_path(table), "/root/rows/row")) { string header = string.Format("INSERT INTO {0} ({1})", table, string.Join(", ", cols.Select(x => "[" + x.Name + "]"))); while (xr.ReadUntilMatch()) { db.exec(header + " VALUES (" + string.Join(", ", cols.Select(x => db.val_toqry(xr[x.AttrName], x.TypeField, type, _nullxml))) + ")"); } } } finally { if (identity) { db.set_identity(table, false); } } }