SqlMetaData 类
定义
从 SqlDataRecord 对象的参数和列指定和检索元数据信息。Specifies and retrieves metadata information from parameters and columns of SqlDataRecord objects. 此类不能被继承。This class cannot be inherited.
public ref class SqlMetaData sealed
public sealed class SqlMetaData
type SqlMetaData = class
Public NotInheritable Class SqlMetaData
- 继承
-
SqlMetaData
示例
下面的示例演示如何创建多个 SqlMetaData 对象,这些对象描述记录的列元数据以及创建 SqlDataRecord 。The following example shows the creation of several SqlMetaData objects, which describe the column metadata of a record, and the creation of a SqlDataRecord. 设置的列值 SqlDataRecord ,并 SqlDataRecord 使用类将发送到调用程序 SqlContext 。The column values of the SqlDataRecord are set and the SqlDataRecord is sent to the calling program using the SqlContext class.
[Microsoft.SqlServer.Server.SqlProcedure]
public static void CreateNewRecord()
{
// Variables.
SqlMetaData column1Info;
SqlMetaData column2Info;
SqlMetaData column3Info;
SqlDataRecord record;
// Create the column metadata.
column1Info = new SqlMetaData("Column1", SqlDbType.NVarChar, 12);
column2Info = new SqlMetaData("Column2", SqlDbType.Int);
column3Info = new SqlMetaData("Column3", SqlDbType.DateTime);
// Create a new record with the column metadata.
record = new SqlDataRecord(new SqlMetaData[] { column1Info,
column2Info,
column3Info });
// Set the record fields.
record.SetString(0, "Hello World!");
record.SetInt32(1, 42);
record.SetDateTime(2, DateTime.Now);
// Send the record to the calling program.
SqlContext.Pipe.Send(record);
}
<Microsoft.SqlServer.Server.SqlProcedure()> _
Public Shared Sub CreateNewRecord()
' Variables.
Dim column1Info As SqlMetaData
Dim column2Info As SqlMetaData
Dim column3Info As SqlMetaData
Dim record As SqlDataRecord
' Create the column metadata.
column1Info = new SqlMetaData("Column1", SqlDbType.NVarChar, 12)
column2Info = new SqlMetaData("Column2", SqlDbType.Int)
column3Info = new SqlMetaData("Column3", SqlDbType.DateTime)
' Create a new record with the column metadata.
record = new SqlDataRecord(new SqlMetaData() { column1Info, _
column2Info, _
column3Info })
' Set the record fields.
record.SetString(0, "Hello World!")
record.SetInt32(1, 42)
record.SetDateTime(2, DateTime.Now)
' Send the record to the calling program.
SqlContext.Pipe.Send(record)
End Sub
构造函数
| SqlMetaData(String, SqlDbType) |
使用指定的列名称和类型初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name and type. |
| SqlMetaData(String, SqlDbType, Boolean, Boolean, SortOrder, Int32) |
使用指定的列名称和默认服务器初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, and default server. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column. |
| SqlMetaData(String, SqlDbType, Byte, Byte) |
使用指定的列名称、类型、精度和小数位数初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, and scale. |
| SqlMetaData(String, SqlDbType, Byte, Byte, Boolean, Boolean, SortOrder, Int32) |
使用指定的列名称、类型、精度、小数位数和服务器默认值初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, precision, scale, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column. |
| SqlMetaData(String, SqlDbType, Int64) |
使用指定的列名称、类型和最大长度初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, and maximum length. |
| SqlMetaData(String, SqlDbType, Int64, Boolean, Boolean, SortOrder, Int32) |
使用指定的列名称、类型、最大长度和服务器默认值初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column. |
| SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type) |
使用指定的列名称、类型、最大长度、精度、小数位数、区域设置 ID、比较选项和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT). |
| SqlMetaData(String, SqlDbType, Int64, Byte, Byte, Int64, SqlCompareOptions, Type, Boolean, Boolean, SortOrder, Int32) |
使用指定的列名称、类型、最大长度、精度、小数位数、区域设置 ID、比较选项和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, precision, scale, locale ID, compare options, and user-defined type (UDT). 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column. |
| SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions) |
使用指定的列名称、类型、最大长度、区域设置和比较选项初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, and compare options. |
| SqlMetaData(String, SqlDbType, Int64, Int64, SqlCompareOptions, Boolean, Boolean, SortOrder, Int32) |
使用指定的列名称、类型、最大长度、区域设置、比较选项和服务器默认值初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, maximum length, locale, compare options, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column. |
| SqlMetaData(String, SqlDbType, String, String, String) |
使用指定的列名称、类型、数据库名称、所属架构和对象名称初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, database name, owning schema, and object name. |
| SqlMetaData(String, SqlDbType, String, String, String, Boolean, Boolean, SortOrder, Int32) |
使用指定的列名称、数据库名称、所属架构、对象名称和默认服务器初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, database name, owning schema, object name, and default server. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column. |
| SqlMetaData(String, SqlDbType, Type) |
使用指定的列名称、类型和用户定义的类型 (UDT) 初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, and user-defined type (UDT). |
| SqlMetaData(String, SqlDbType, Type, String) |
使用指定的列名称、用户定义的类型 (UDT) 和 SQLServer 类型初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, user-defined type (UDT), and SQLServer type. |
| SqlMetaData(String, SqlDbType, Type, String, Boolean, Boolean, SortOrder, Int32) |
使用指定的列名称、类型、用户定义的类型、SQL Server 类型和服务器默认值初始化 SqlMetaData 类的新实例。Initializes a new instance of the SqlMetaData class with the specified column name, type, user-defined type, SQL Server type, and server default. 这种形式的构造函数通过允许指定表值参数中的列是否唯一、列的排序顺序和列排序的序号,支持表值参数。This form of the constructor supports table-valued parameters by allowing you to specify if the column is unique in the table-valued parameter, the sort order for the column, and the ordinal of the sort column. |
属性
| CompareOptions |
获取用于列或参数的比较规则。Gets the comparison rules used for the column or parameter. |
| DbType |
获取列或参数的数据类型。Gets the data type of the column or parameter. |
| IsUniqueKey |
指示表值参数中的列是否唯一。Indicates if the column in the table-valued parameter is unique. |
| LocaleId |
获取列或参数的区域设置 ID。Gets the locale ID of the column or parameter. |
| Max |
获取 |
| MaxLength |
获取列或参数的最大长度。Gets the maximum length of the column or parameter. |
| Name |
获取列或参数的名称。Gets the name of the column or parameter. |
| Precision |
获取列或参数的精度。Gets the precision of the column or parameter. |
| Scale |
获取列或参数的小数位数。Gets the scale of the column or parameter. |
| SortOrder |
返回列的排序顺序。Returns the sort order for a column. |
| SortOrdinal |
返回列排序的序号。Returns the ordinal of the sort column. |
| SqlDbType |
获取列或参数的数据类型。Gets the data type of the column or parameter. |
| Type |
获取用户定义的类型 (UDT) 的公共语言运行时 (CLR) 类型。Gets the common language runtime (CLR) type of a user-defined type (UDT). |
| TypeName |
获取该实例所表示的用户定义的类型 (UDT) 或 SQL Server 类型的名称,名称由三部分组成。Gets the three-part name of the user-defined type (UDT) or the SQL Server type represented by the instance. |
| UseServerDefault |
报告此列是否应使用默认服务器值。Reports whether this column should use the default server value. |
| XmlSchemaCollectionDatabase |
获取此 XML 实例的架构集合所在的数据库的名称。Gets the name of the database where the schema collection for this XML instance is located. |
| XmlSchemaCollectionName |
获取此 XML 实例的架构集合的名称。Gets the name of the schema collection for this XML instance. |
| XmlSchemaCollectionOwningSchema |
获取此 XML 实例的架构集合所在的所属关系架构。Gets the owning relational schema where the schema collection for this XML instance is located. |
方法
| Adjust(Boolean) |
根据元数据验证指定的 Boolean 值,并在需要时调整该值。Validates the specified Boolean value against the metadata, and adjusts the value if necessary. |
| Adjust(Byte) |
根据元数据验证指定的 Byte 值,并在需要时调整该值。Validates the specified Byte value against the metadata, and adjusts the value if necessary. |
| Adjust(Byte[]) |
根据元数据验证指定的 Byte 值的数组,并在需要时调整该值。Validates the specified array of Byte values against the metadata, and adjusts the value if necessary. |
| Adjust(Char) |
根据元数据验证指定的 Char 值,并在需要时调整该值。Validates the specified Char value against the metadata, and adjusts the value if necessary. |
| Adjust(Char[]) |
根据元数据验证指定的 Char 值的数组,并在需要时调整该值。Validates the specified array of Char values against the metadata, and adjusts the value if necessary. |
| Adjust(DateTime) |
根据元数据验证指定的 DateTime 值,并在需要时调整该值。Validates the specified DateTime value against the metadata, and adjusts the value if necessary. |
| Adjust(DateTimeOffset) |
根据元数据验证指定的 DateTimeOffset 值,并在需要时调整该值。Validates the specified DateTimeOffset value against the metadata, and adjusts the value if necessary. |
| Adjust(Decimal) |
根据元数据验证指定的 Decimal 值,并在需要时调整该值。Validates the specified Decimal value against the metadata, and adjusts the value if necessary. |
| Adjust(Double) |
根据元数据验证指定的 Double 值,并在需要时调整该值。Validates the specified Double value against the metadata, and adjusts the value if necessary. |
| Adjust(Guid) |
根据元数据验证指定的 Guid 值,并在需要时调整该值。Validates the specified Guid value against the metadata, and adjusts the value if necessary. |
| Adjust(Int16) |
根据元数据验证指定的 Int16 值,并在需要时调整该值。Validates the specified Int16 value against the metadata, and adjusts the value if necessary. |
| Adjust(Int32) |
根据元数据验证指定的 Int32 值,并在需要时调整该值。Validates the specified Int32 value against the metadata, and adjusts the value if necessary. |
| Adjust(Int64) |
根据元数据验证指定的 Int64 值,并在需要时调整该值。Validates the specified Int64 value against the metadata, and adjusts the value if necessary. |
| Adjust(Object) |
根据元数据验证指定的 Object 值,并在需要时调整该值。Validates the specified Object value against the metadata, and adjusts the value if necessary. |
| Adjust(Single) |
根据元数据验证指定的 Single 值,并在需要时调整该值。Validates the specified Single value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlBinary) |
根据元数据验证指定的 SqlBinary 值,并在需要时调整该值。Validates the specified SqlBinary value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlBoolean) |
根据元数据验证指定的 SqlBoolean 值,并在需要时调整该值。Validates the specified SqlBoolean value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlByte) |
根据元数据验证指定的 SqlByte 值,并在需要时调整该值。Validates the specified SqlByte value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlBytes) |
根据元数据验证指定的 SqlBytes 值,并在需要时调整该值。Validates the specified SqlBytes value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlChars) |
根据元数据验证指定的 SqlChars 值,并在需要时调整该值。Validates the specified SqlChars value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlDateTime) |
根据元数据验证指定的 SqlDateTime 值,并在需要时调整该值。Validates the specified SqlDateTime value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlDecimal) |
根据元数据验证指定的 SqlDecimal 值,并在需要时调整该值。Validates the specified SqlDecimal value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlDouble) |
根据元数据验证指定的 SqlDouble 值,并在需要时调整该值。Validates the specified SqlDouble value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlGuid) |
根据元数据验证指定的 SqlGuid 值,并在需要时调整该值。Validates the specified SqlGuid value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlInt16) |
根据元数据验证指定的 SqlInt16 值,并在需要时调整该值。Validates the specified SqlInt16 value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlInt32) |
根据元数据验证指定的 SqlInt32 值,并在需要时调整该值。Validates the specified SqlInt32 value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlInt64) |
根据元数据验证指定的 SqlInt64 值,并在需要时调整该值。Validates the specified SqlInt64 value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlMoney) |
根据元数据验证指定的 SqlMoney 值,并在需要时调整该值。Validates the specified SqlMoney value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlSingle) |
根据元数据验证指定的 SqlSingle 值,并在需要时调整该值。Validates the specified SqlSingle value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlString) |
根据元数据验证指定的 SqlString 值,并在需要时调整该值。Validates the specified SqlString value against the metadata, and adjusts the value if necessary. |
| Adjust(SqlXml) |
根据元数据验证指定的 SqlXml 值,并在需要时调整该值。Validates the specified SqlXml value against the metadata, and adjusts the value if necessary. |
| Adjust(String) |
根据元数据验证指定的 String 值,并在需要时调整该值。Validates the specified String value against the metadata, and adjusts the value if necessary. |
| Adjust(TimeSpan) |
根据元数据验证指定的 TimeSpan 值,并在需要时调整该值。Validates the specified TimeSpan value against the metadata, and adjusts the value if necessary. |
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| InferFromValue(Object, String) |
从指定的对象推导出元数据,并将它作为 SqlMetaData 实例返回。Infers the metadata from the specified object and returns it as a SqlMetaData instance. |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |