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. 若要取得含有 DiffGram 的 ReadXml(XmlReader) 輸入,您應該只使用來自 WriteXml(Stream) 且為 DiffGram 形式的輸出。Input to ReadXml(XmlReader) with DiffGrams should only be obtained using the output from WriteXml(Stream) as a DiffGram.

目標 DataSet 必須與 DataSet 呼叫 DiffGram 所在 WriteXml 具有相同的結構描述。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

讀取 XML 片段,例如針對 SQL Server 的執行個體執行 FOR 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,則 IgnoreSchema 具有與 DiffGram 相同的功能。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.

備註

設定 DataSet.ReadXml 方法的 ReadMode 參數時,請使用這個列舉的成員。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.

適用於