假设我创建了一个DataTable对象,该对象创建了一个名为“5_min”的列。我通常提取Schema来为后续实例创建相同DataSet的实例。
架构将列名5_min
重写为_x0035__min
。我想知道如何防止这种情况发生?
DataTable newDT = new DataTable("SomeDataTable");
DataColumn[] keys = new DataColumn[1];
DataColumn dcID = new DataColumn("ID");
dcID.DataType = System.Type.GetType("System.Guid");
newDT.Columns.Add(dcID);
keys[0] = dcID;
newDT.PrimaryKey = keys;
var dataTypes = DA.GetSysVars(GlobalSysVar.DataTypes);
DataColumn dcColumn = new DataColumn("5_min");
dcColumn.DataType = System.Type.GetType("System.String");
dcColumn.AllowDBNull = true;
newDT.Columns.Add(dcColumn);
DataSet ds = new DataSet("Custom");
ds.Tables.Add(newDT);
<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="Custom" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="Custom" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="SomeDataTable">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" />
<xs:element name="_x0035__min" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//SomeDataTable" />
<xs:field xpath="ID" />
</xs:unique>
</xs:element>
</xs:schema>