Esempio n. 1
0
 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();
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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;
     }
 }