public string val_to_qry(string field, db_schema db_ref) { schema_field sfld = get_field(field); return(db_ref.val_toqry(_xr[sfld.AttrName], sfld.TypeField, db_schema.null_value)); }
public string val_to_qry(string val, string field, db_schema db_ref) { return(db_ref.val_toqry(val == null ? db_schema.null_value : val, get_field(field).TypeField, db_schema.null_value)); }
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); } } }