2002-10-31 Tim Coleman (tim@timcoleman.com)
authorTim Coleman <tim@mono-cvs.ximian.com>
Fri, 1 Nov 2002 01:40:55 +0000 (01:40 -0000)
committerTim Coleman <tim@mono-cvs.ximian.com>
Fri, 1 Nov 2002 01:40:55 +0000 (01:40 -0000)
        * TdsSchemaInfo.cs:
                Added because I can't really use SchemaInfo
        * ITds.cs:
        * Tds.cs :
        * TdsPacketColumnInfoResult.cs :
                ChangeDefinition of schema
        * Tds42.cs :
        * Tds50.cs :
        * Tds70.cs :
                Add new information to schema

svn path=/trunk/mcs/; revision=8721

14 files changed:
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/ITds.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds42.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds50.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/Tds70.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsPacketColumnInfoResult.cs
mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsSchemaInfo.cs [new file with mode: 0644]
mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/ITds.cs
mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/Tds.cs
mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/Tds42.cs
mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/Tds50.cs
mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/Tds70.cs
mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsPacketColumnInfoResult.cs
mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsSchemaInfo.cs [new file with mode: 0644]

index 3566f0dff8d5922bfc74c1c1cb7223042e1d0c12..9833b52df935ca118e1197447f9209a84b3806ee 100644 (file)
@@ -28,7 +28,7 @@ namespace Mono.Data.TdsClient.Internal {
                        get;
                }
 
-               SchemaInfo[] Schema {
+               TdsPacketColumnInfoResult Schema {
                        get;
                }
 
index 5732fd99975d3efc98bd594fcd27e40fafadb181..45545c9e118ae29a3b5ce3c75a4ef01b4fc06563 100644 (file)
@@ -103,8 +103,8 @@ namespace Mono.Data.TdsClient.Internal {
                        get { return databaseProductVersion; }
                }
 
-               public SchemaInfo[] Schema {
-                       get { return columnInfo.Schema; }
+               public TdsPacketColumnInfoResult Schema {
+                       get { return columnInfo; }
                }
 
                public TdsPacketRowResult ColumnValues {
@@ -642,8 +642,8 @@ namespace Mono.Data.TdsClient.Internal {
                        TdsPacketRowResult result = new TdsPacketRowResult (context);
 
                        int i = 0;
-                       foreach (TdsColumnType type in columnInfo.ColumnTypes) {
-                               result.Add (GetColumnValue (type, false, i));
+                       foreach (TdsSchemaInfo schema in columnInfo) {
+                               result.Add (GetColumnValue (schema.ColumnType, false, i));
                                i += 1;
                        }
 
index db44b132ea12f394ff2e1fcb77e4949ae4540ff0..7654f8fa27ae0b605f419212eedd9e5543a5c347 100644 (file)
@@ -265,17 +265,15 @@ namespace Mono.Data.TdsClient.Internal {
                                        bytesRead += 1;
                                }
 
-                               int index = result.Add (new SchemaInfo ());
-                               result[index].DataTypeName = columnType.ToString ();
+                               int index = result.Add (new TdsSchemaInfo ());
                                result[index].NumericPrecision = precision;
                                result[index].NumericScale = scale;
                                result[index].ColumnSize = bufLength;
                                result[index].ColumnName = ColumnNames[index];
+                               result[index].ColumnType = columnType;
                                result[index].TableName = tableName;
-                               result[index].Nullable = nullable;
-                               result[index].Writable = writable;
-
-                               result.Add (columnType);
+                               result[index].AllowDBNull = nullable;
+                               result[index].IsReadOnly = !writable;
                        }
 
                        //int skipLength = totalLength - bytesRead;
index e66adf9b3806529ec068920a0a0f8b9b8447dcd7..706931f348b58f974c913d95cdd8482796d4e91f 100644 (file)
@@ -261,17 +261,15 @@ namespace Mono.Data.TdsClient.Internal {
                                        bytesRead += 1;
                                }
 
-                               int index = result.Add (new SchemaInfo ());
-                               result[index].DataTypeName = columnType.ToString ();
+                               int index = result.Add (new TdsSchemaInfo ());
                                result[index].NumericPrecision = precision;
                                result[index].NumericScale = scale;
                                result[index].ColumnSize = bufLength;
                                result[index].ColumnName = ColumnNames[index];
                                result[index].TableName = tableName;
-                               result[index].Nullable = nullable;
-                               result[index].Writable = writable;
-
-                               result.Add (columnType);
+                               result[index].AllowDBNull = nullable;
+                               result[index].IsReadOnly = !writable;
+                               result[index].ColumnType = columnType;
                        }
 
                        //int skipLength = totalLength - bytesRead;
index 4406b792340b3488c2bbdcc6b3b941a813545a9c..458aa08ca7702fcd584df15ae67327f704a31239 100644 (file)
@@ -199,6 +199,7 @@ namespace Mono.Data.TdsClient.Internal {
                                bool caseSensitive = (flagData[2] & 0x02) > 0;
                                bool writable = (flagData[2] & 0x0c) > 0;
                                bool autoIncrement = (flagData[2] & 0x10) > 0;
+                               bool isIdentity = (flagData[2] & 0x10) > 0;
 
                                TdsColumnType columnType = (TdsColumnType) (Comm.GetByte () & 0xff);
                                if ((byte) columnType == 0xef)
@@ -213,7 +214,7 @@ namespace Mono.Data.TdsClient.Internal {
 
                                //int dispSize = -1;
                                int bufLength;
-                               string tableName = "";
+                               string tableName = null;
 
                                if (IsBlobType (columnType)) {
                                        bufLength = Comm.GetTdsInt ();
@@ -237,17 +238,16 @@ namespace Mono.Data.TdsClient.Internal {
                                int colNameLength = Comm.GetByte ();
                                string columnName = Comm.GetString (colNameLength);
 
-                               int index = result.Add (new SchemaInfo ());
-                               result[index].DataTypeName = columnType.ToString ();
+                               int index = result.Add (new TdsSchemaInfo ());
+                               result[index].AllowDBNull = nullable;
+                               result[index].ColumnName = columnName;
+                               result[index].ColumnSize = bufLength;
+                               result[index].ColumnType = columnType;
+                               result[index].IsIdentity = isIdentity;
+                               result[index].IsReadOnly = !writable;
                                result[index].NumericPrecision = precision;
                                result[index].NumericScale = scale;
-                               result[index].ColumnSize = bufLength;
-                               result[index].ColumnName = columnName;
                                result[index].TableName = tableName;
-                               result[index].Nullable = nullable;
-                               result[index].Writable = writable;
-
-                               result.Add (columnType);
                        }
 
                        return result;
index a0147e9075db541915bf33a98cb49da902e031fb..43055f5c5cb5b5e4c2bf2b52dc7827c1b5a36b48 100644 (file)
@@ -17,7 +17,6 @@ namespace Mono.Data.TdsClient.Internal {
                #region Fields
 
                ArrayList list;
-               ArrayList columnTypes;
                
                #endregion // Fields
 
@@ -27,31 +26,22 @@ namespace Mono.Data.TdsClient.Internal {
                        : base (TdsPacketSubType.ColumnNameToken)
                {
                        list = new ArrayList ();
-                       columnTypes = new ArrayList ();
                }
 
                #endregion // Constructors
 
                #region Properties
 
-               public SchemaInfo[] Schema {
-                       get { return (SchemaInfo[]) list.ToArray (typeof (SchemaInfo)); }
-               }
-
-               public SchemaInfo this [int index] {
-                       get { return (SchemaInfo) list[index]; }
+               public TdsSchemaInfo this [int index] {
+                       get { return (TdsSchemaInfo) list[index]; }
                        set { list[index] = value; }
                }
 
-               public ArrayList ColumnTypes {
-                       get { return columnTypes; }
-               }
-
                #endregion // Properties
 
                #region Methods
 
-               public int Add (SchemaInfo schema)
+               public int Add (TdsSchemaInfo schema)
                {
                        int index;
                        index = list.Add (schema);
@@ -64,11 +54,6 @@ namespace Mono.Data.TdsClient.Internal {
                        return list.GetEnumerator ();
                }
 
-               public int Add (TdsColumnType columnType)
-               {
-                       return columnTypes.Add (columnType);
-               }
-
                #endregion // Methods
        }
 }
diff --git a/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsSchemaInfo.cs b/mcs/class/Mono.Data.Tds/Mono.Data.Tds.Protocol/TdsSchemaInfo.cs
new file mode 100644 (file)
index 0000000..e341d7d
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// System.Data.Common.TdsSchemaInfo.cs
+//
+// Author:
+//   Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+namespace Mono.Data.TdsClient.Internal {
+       internal class TdsSchemaInfo
+       {
+               #region Fields
+
+               string columnName;
+               string tableName;
+               TdsColumnType columnType;
+               object value;
+               bool nullable;
+               bool isReadOnly;
+               bool isIdentity = false;
+               bool isKey;
+               int ordinal;
+               int size;
+               byte precision;
+               byte scale;
+
+               #endregion // Fields
+
+               #region Constructors
+
+               public TdsSchemaInfo ()
+               {
+               }
+
+               #endregion // Constructors
+
+               #region Properties
+
+               public bool AllowDBNull {
+                       get { return nullable; }
+                       set { nullable = value; }
+               }
+
+               public int ColumnOrdinal {
+                       get { return ordinal; }
+                       set { ordinal = value; }
+               }
+
+               public string ColumnName {
+                       get { return columnName; }
+                       set { columnName = value; }
+               }
+
+               public int ColumnSize {
+                       get { return size; }
+                       set { size = value; }
+               }
+
+               public TdsColumnType ColumnType {
+                       get { return columnType; }
+                       set { columnType = value; }
+               }
+
+               public bool IsIdentity {
+                       get { return isIdentity; }
+                       set { isIdentity = value; }
+               }
+
+               public bool IsKey {     
+                       get { return isKey; }
+                       set { isKey = value; }
+               }
+
+               public bool IsReadOnly {
+                       get { return isReadOnly; }
+                       set { isReadOnly = value; }
+               }
+               
+               public byte NumericPrecision {
+                       get { return precision; }
+                       set { precision = value; }
+               }
+
+               public byte NumericScale {
+                       get { return scale; }
+                       set { scale = value; }
+               }
+
+               public string TableName {
+                       get { return tableName; }
+                       set { tableName = value; }
+               }
+
+               #endregion // Properties
+
+       }
+}
index 3566f0dff8d5922bfc74c1c1cb7223042e1d0c12..9833b52df935ca118e1197447f9209a84b3806ee 100644 (file)
@@ -28,7 +28,7 @@ namespace Mono.Data.TdsClient.Internal {
                        get;
                }
 
-               SchemaInfo[] Schema {
+               TdsPacketColumnInfoResult Schema {
                        get;
                }
 
index 5732fd99975d3efc98bd594fcd27e40fafadb181..45545c9e118ae29a3b5ce3c75a4ef01b4fc06563 100644 (file)
@@ -103,8 +103,8 @@ namespace Mono.Data.TdsClient.Internal {
                        get { return databaseProductVersion; }
                }
 
-               public SchemaInfo[] Schema {
-                       get { return columnInfo.Schema; }
+               public TdsPacketColumnInfoResult Schema {
+                       get { return columnInfo; }
                }
 
                public TdsPacketRowResult ColumnValues {
@@ -642,8 +642,8 @@ namespace Mono.Data.TdsClient.Internal {
                        TdsPacketRowResult result = new TdsPacketRowResult (context);
 
                        int i = 0;
-                       foreach (TdsColumnType type in columnInfo.ColumnTypes) {
-                               result.Add (GetColumnValue (type, false, i));
+                       foreach (TdsSchemaInfo schema in columnInfo) {
+                               result.Add (GetColumnValue (schema.ColumnType, false, i));
                                i += 1;
                        }
 
index db44b132ea12f394ff2e1fcb77e4949ae4540ff0..7654f8fa27ae0b605f419212eedd9e5543a5c347 100644 (file)
@@ -265,17 +265,15 @@ namespace Mono.Data.TdsClient.Internal {
                                        bytesRead += 1;
                                }
 
-                               int index = result.Add (new SchemaInfo ());
-                               result[index].DataTypeName = columnType.ToString ();
+                               int index = result.Add (new TdsSchemaInfo ());
                                result[index].NumericPrecision = precision;
                                result[index].NumericScale = scale;
                                result[index].ColumnSize = bufLength;
                                result[index].ColumnName = ColumnNames[index];
+                               result[index].ColumnType = columnType;
                                result[index].TableName = tableName;
-                               result[index].Nullable = nullable;
-                               result[index].Writable = writable;
-
-                               result.Add (columnType);
+                               result[index].AllowDBNull = nullable;
+                               result[index].IsReadOnly = !writable;
                        }
 
                        //int skipLength = totalLength - bytesRead;
index e66adf9b3806529ec068920a0a0f8b9b8447dcd7..706931f348b58f974c913d95cdd8482796d4e91f 100644 (file)
@@ -261,17 +261,15 @@ namespace Mono.Data.TdsClient.Internal {
                                        bytesRead += 1;
                                }
 
-                               int index = result.Add (new SchemaInfo ());
-                               result[index].DataTypeName = columnType.ToString ();
+                               int index = result.Add (new TdsSchemaInfo ());
                                result[index].NumericPrecision = precision;
                                result[index].NumericScale = scale;
                                result[index].ColumnSize = bufLength;
                                result[index].ColumnName = ColumnNames[index];
                                result[index].TableName = tableName;
-                               result[index].Nullable = nullable;
-                               result[index].Writable = writable;
-
-                               result.Add (columnType);
+                               result[index].AllowDBNull = nullable;
+                               result[index].IsReadOnly = !writable;
+                               result[index].ColumnType = columnType;
                        }
 
                        //int skipLength = totalLength - bytesRead;
index 4406b792340b3488c2bbdcc6b3b941a813545a9c..458aa08ca7702fcd584df15ae67327f704a31239 100644 (file)
@@ -199,6 +199,7 @@ namespace Mono.Data.TdsClient.Internal {
                                bool caseSensitive = (flagData[2] & 0x02) > 0;
                                bool writable = (flagData[2] & 0x0c) > 0;
                                bool autoIncrement = (flagData[2] & 0x10) > 0;
+                               bool isIdentity = (flagData[2] & 0x10) > 0;
 
                                TdsColumnType columnType = (TdsColumnType) (Comm.GetByte () & 0xff);
                                if ((byte) columnType == 0xef)
@@ -213,7 +214,7 @@ namespace Mono.Data.TdsClient.Internal {
 
                                //int dispSize = -1;
                                int bufLength;
-                               string tableName = "";
+                               string tableName = null;
 
                                if (IsBlobType (columnType)) {
                                        bufLength = Comm.GetTdsInt ();
@@ -237,17 +238,16 @@ namespace Mono.Data.TdsClient.Internal {
                                int colNameLength = Comm.GetByte ();
                                string columnName = Comm.GetString (colNameLength);
 
-                               int index = result.Add (new SchemaInfo ());
-                               result[index].DataTypeName = columnType.ToString ();
+                               int index = result.Add (new TdsSchemaInfo ());
+                               result[index].AllowDBNull = nullable;
+                               result[index].ColumnName = columnName;
+                               result[index].ColumnSize = bufLength;
+                               result[index].ColumnType = columnType;
+                               result[index].IsIdentity = isIdentity;
+                               result[index].IsReadOnly = !writable;
                                result[index].NumericPrecision = precision;
                                result[index].NumericScale = scale;
-                               result[index].ColumnSize = bufLength;
-                               result[index].ColumnName = columnName;
                                result[index].TableName = tableName;
-                               result[index].Nullable = nullable;
-                               result[index].Writable = writable;
-
-                               result.Add (columnType);
                        }
 
                        return result;
index a0147e9075db541915bf33a98cb49da902e031fb..43055f5c5cb5b5e4c2bf2b52dc7827c1b5a36b48 100644 (file)
@@ -17,7 +17,6 @@ namespace Mono.Data.TdsClient.Internal {
                #region Fields
 
                ArrayList list;
-               ArrayList columnTypes;
                
                #endregion // Fields
 
@@ -27,31 +26,22 @@ namespace Mono.Data.TdsClient.Internal {
                        : base (TdsPacketSubType.ColumnNameToken)
                {
                        list = new ArrayList ();
-                       columnTypes = new ArrayList ();
                }
 
                #endregion // Constructors
 
                #region Properties
 
-               public SchemaInfo[] Schema {
-                       get { return (SchemaInfo[]) list.ToArray (typeof (SchemaInfo)); }
-               }
-
-               public SchemaInfo this [int index] {
-                       get { return (SchemaInfo) list[index]; }
+               public TdsSchemaInfo this [int index] {
+                       get { return (TdsSchemaInfo) list[index]; }
                        set { list[index] = value; }
                }
 
-               public ArrayList ColumnTypes {
-                       get { return columnTypes; }
-               }
-
                #endregion // Properties
 
                #region Methods
 
-               public int Add (SchemaInfo schema)
+               public int Add (TdsSchemaInfo schema)
                {
                        int index;
                        index = list.Add (schema);
@@ -64,11 +54,6 @@ namespace Mono.Data.TdsClient.Internal {
                        return list.GetEnumerator ();
                }
 
-               public int Add (TdsColumnType columnType)
-               {
-                       return columnTypes.Add (columnType);
-               }
-
                #endregion // Methods
        }
 }
diff --git a/mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsSchemaInfo.cs b/mcs/class/Mono.Data.TdsClient/Mono.Data.TdsClient.Internal/TdsSchemaInfo.cs
new file mode 100644 (file)
index 0000000..e341d7d
--- /dev/null
@@ -0,0 +1,98 @@
+//
+// System.Data.Common.TdsSchemaInfo.cs
+//
+// Author:
+//   Tim Coleman (tim@timcoleman.com)
+//
+// Copyright (C) Tim Coleman, 2002
+//
+
+namespace Mono.Data.TdsClient.Internal {
+       internal class TdsSchemaInfo
+       {
+               #region Fields
+
+               string columnName;
+               string tableName;
+               TdsColumnType columnType;
+               object value;
+               bool nullable;
+               bool isReadOnly;
+               bool isIdentity = false;
+               bool isKey;
+               int ordinal;
+               int size;
+               byte precision;
+               byte scale;
+
+               #endregion // Fields
+
+               #region Constructors
+
+               public TdsSchemaInfo ()
+               {
+               }
+
+               #endregion // Constructors
+
+               #region Properties
+
+               public bool AllowDBNull {
+                       get { return nullable; }
+                       set { nullable = value; }
+               }
+
+               public int ColumnOrdinal {
+                       get { return ordinal; }
+                       set { ordinal = value; }
+               }
+
+               public string ColumnName {
+                       get { return columnName; }
+                       set { columnName = value; }
+               }
+
+               public int ColumnSize {
+                       get { return size; }
+                       set { size = value; }
+               }
+
+               public TdsColumnType ColumnType {
+                       get { return columnType; }
+                       set { columnType = value; }
+               }
+
+               public bool IsIdentity {
+                       get { return isIdentity; }
+                       set { isIdentity = value; }
+               }
+
+               public bool IsKey {     
+                       get { return isKey; }
+                       set { isKey = value; }
+               }
+
+               public bool IsReadOnly {
+                       get { return isReadOnly; }
+                       set { isReadOnly = value; }
+               }
+               
+               public byte NumericPrecision {
+                       get { return precision; }
+                       set { precision = value; }
+               }
+
+               public byte NumericScale {
+                       get { return scale; }
+                       set { scale = value; }
+               }
+
+               public string TableName {
+                       get { return tableName; }
+                       set { tableName = value; }
+               }
+
+               #endregion // Properties
+
+       }
+}