internal RecordSetAdapter(DbDataAdapter dbAdapter, string tblName, RecordSet rs) { RS = rs; DbAdapter = dbAdapter; TableName = tblName; setColumns = RS.Columns.Where(c => !c.ReadOnly).ToArray(); autoIncrementCol = RS.Columns.Where(c => c.AutoIncrement).FirstOrDefault(); }
internal static RecordSet GetRecordSetByReader(IDataReader rdr) { var rsCols = new List <RecordSet.Column>(rdr.FieldCount); var rsPkCols = new List <RecordSet.Column>(); #if NET_STANDARD // lets populate data schema if (rdr is DbDataReader) { var dbRdr = (DbDataReader)rdr; if (dbRdr.CanGetColumnSchema()) { foreach (var dbCol in dbRdr.GetColumnSchema()) { var c = new RecordSet.Column(dbCol); rsCols.Add(c); if (dbCol.IsKey.HasValue && dbCol.IsKey.Value) { rsPkCols.Add(c); } } } } #endif if (rsCols.Count == 0) { // lets suggest columns by standard IDataReader interface for (int i = 0; i < rdr.FieldCount; i++) { var colName = rdr.GetName(i); var colType = rdr.GetFieldType(i); rsCols.Add(new RecordSet.Column(colName, colType)); } } var rs = new RecordSet(rsCols.ToArray(), 1); if (rsPkCols.Count > 0) { rs.PrimaryKey = rsPkCols.ToArray(); } return(rs); }
public void Dispose() { RS = null; DbAdapter = null; setColumns = null; autoIncrementCol = null; if (InsertCmd != null) { InsertCmd.Dispose(); InsertCmd = null; } if (UpdateCmd != null) { UpdateCmd.Dispose(); UpdateCmd = null; } if (DeleteCmd != null) { DeleteCmd.Dispose(); DeleteCmd = null; } }