XmlReadMode 枚举

定义

指定如何将 XML 数据和关系架构读入 DataSetSpecifies how to read XML data and a relational schema into a DataSet.

public enum class XmlReadMode
public enum XmlReadMode
type XmlReadMode = 
Public Enum XmlReadMode
继承
XmlReadMode

字段

Auto 0

默认的读取模式。The default read mode.

DiffGram 4

读取 DiffGram,将 DiffGram 中的更改应用到 DataSetReads a DiffGram, applying changes from the DiffGram to the DataSet. 语义与 Merge(DataSet) 操作的语义相同。The semantics are identical to those of a Merge(DataSet) operation. Merge(DataSet) 操作一样,保留 RowState 值。As with the Merge(DataSet) operation, RowState values are preserved. ReadXml(XmlReader) 的 DiffGram 输入只能使用 WriteXml(Stream) 中的 DiffGram 输出来获得。Input to ReadXml(XmlReader) with DiffGrams should only be obtained using the output from WriteXml(Stream) as a DiffGram.

目标 DataSet 必须与在其中将 WriteXml 作为 DiffGram 调用的 DataSet 具有相同架构。The target DataSet must have the same schema as the DataSet on which WriteXml as DiffGram is called. 否则,DiffGram 合并操作会失败并引发异常。Otherwise the DiffGram merge operation fails and an exception is thrown.

Fragment 5

针对 SQL Server 的实例读取 XML 片段(例如,通过执行 FOR XML 查询生成的 XML 片段)。Reads XML fragments, such as those generated by executing FOR XML queries, against an instance of SQL Server. XmlReadMode 设置为 Fragment 时,将默认命名空间作为内联架构读取。When XmlReadMode is set to Fragment, the default namespace is read as the inline schema.

IgnoreSchema 2

忽略任何内联架构并将数据读入现有的 DataSet 架构。Ignores any inline schema and reads data into the existing DataSet schema. 如果任何数据与现有架构不匹配,就会丢弃这些数据(包括为 DataSet 定义的不同命名空间中的数据)。If any data does not match the existing schema, it is discarded (including data from differing namespaces defined for the DataSet). 如果数据是 DiffGram,IgnoreSchemaDiffGram 具有相同的功能。If the data is a DiffGram, IgnoreSchema has the same functionality as DiffGram.

InferSchema 3

忽略任何内联架构,从数据推断出架构并加载数据。Ignores any inline schema, infers schema from the data and loads the data. 如果 DataSet 已包含架构,通过添加新表或将列添加到现有表来扩展当前架构。If the DataSet already contains a schema, the current schema is extended by adding new tables or adding columns to existing tables. 如果推断表已经存在,但命名空间不同,或者任何推断列与现有列冲突,则会引发异常。An exception is thrown if the inferred table already exists but with a different namespace, or if any of the inferred columns conflict with existing columns.

InferTypedSchema 6

忽略任何内联架构,从数据推断出强类型架构并加载数据。Ignores any inline schema, infers a strongly typed schema from the data, and loads the data. 如果无法从数据中推断出类型,则将其解释为字符串数据。If the type cannot be inferred from the data, it is interpreted as string data. 如果 DataSet 已包含架构,则通过添加新表或向现有表添加列来扩展当前架构。If the DataSet already contains a schema, the current schema is extended, either by adding new tables or by adding columns to existing tables. 如果推断表已经存在,但命名空间不同,或者任何推断列与现有列冲突,则会引发异常。An exception is thrown if the inferred table already exists but with a different namespace, or if any of the inferred columns conflict with existing columns.

ReadSchema 1

读取任何内联架构并加载数据。Reads any inline schema and loads the data. 如果 DataSet 已包含架构,则可将新表添加到架构中,但是如果内联架构中的任何表在 DataSet 中已经存在,则会引发异常。If the DataSet already contains schema, new tables may be added to the schema, but an exception is thrown if any tables in the inline schema already exist in the DataSet.

注解

设置ReadMode DataSet.ReadXml方法的参数时, 请使用此枚举的成员。Use the members of this enumeration when setting the ReadMode parameter of the DataSet.ReadXml method.

备注

Auto模式可能比设置XmlReadMode为显式选项慢。Auto mode may be slower than setting XmlReadMode to an explicit option.

Auto执行以下最适当的操作:Auto performs the most appropriate of these actions:

  • 如果数据为 DiffGram, 则将 XML 读取模式设置为DiffGramIf the data is a DiffGram, sets the XML read mode to DiffGram.

  • 如果数据集已具有架构, 或者如果文档包含内嵌架构, 则将 XML 读取模式设置为ReadSchemaIf the dataset already has a schema, or if the document contains an in-line schema, sets the XML read mode to ReadSchema.

  • 如果数据集尚未包含架构并且文档不包含内联架构, 则将 XML 读取模式设置为InferSchemaIf the dataset does not already have a schema and the document does not contain an in-line schema, sets the XML read mode to InferSchema.

适用于