DataSet.WriteXmlSchema 方法

定义

写 XML 架构形式的 DataSet 结构。

重载

WriteXmlSchema(String, Converter<Type,String>)

将 XML 架构形式的 DataSet 结构写入文件。

WriteXmlSchema(Stream)

DataSet 结构作为 XML 架构写入指定的 Stream 对象。

WriteXmlSchema(TextWriter)

DataSet 结构作为 XML 架构写入指定的 TextWriter 对象。

WriteXmlSchema(String)

将 XML 架构形式的 DataSet 结构写入文件。

WriteXmlSchema(XmlWriter)

将 XML 架构形式的 DataSet 结构写入 XmlWriter 对象。

WriteXmlSchema(Stream, Converter<Type,String>)

DataSet 结构作为 XML 架构写入指定的 Stream 对象。

WriteXmlSchema(TextWriter, Converter<Type,String>)

DataSet 结构作为一个 XML 架构写入指定的 TextWriter

WriteXmlSchema(XmlWriter, Converter<Type,String>)

DataSet 结构作为一个 XML 架构写入指定的 XmlWriter

WriteXmlSchema(String, Converter<Type,String>)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

将 XML 架构形式的 DataSet 结构写入文件。

C#
public void WriteXmlSchema (string fileName, Converter<Type,string> multipleTargetConverter);

参数

fileName
String

要写入的文件的名称。

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteXmlSchema(Stream)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

DataSet 结构作为 XML 架构写入指定的 Stream 对象。

C#
public void WriteXmlSchema (System.IO.Stream? stream);
C#
public void WriteXmlSchema (System.IO.Stream stream);

参数

stream
Stream

用于写入文件的 Stream 对象。

示例

以下示例创建一个新的 FileStream 对象,该对象传递给 WriteXmlSchema 方法,以将架构写入磁盘。

C#
private void WriteSchemaWithFileStream(DataSet thisDataSet)
{
    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Create the FileStream object with the file name.
    // Use FileMode.Create.
    System.IO.FileStream stream =
        new System.IO.FileStream(filename,System.IO.FileMode.Create);

    // Write the schema to the file.
    thisDataSet.WriteXmlSchema(stream);

    // Close the FileStream.
    stream.Close();
}

注解

WriteXmlSchema使用 方法将 的DataSet架构写入 XML 文档。 架构包括表、关系和约束定义。 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。

XML 架构是使用 XSD 标准编写的。

若要将数据写入 XML 文档,请使用 WriteXml 方法。

派生自 类的 Stream 类包括 BufferedStreamFileStreamMemoryStreamNetworkStream

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteXmlSchema(TextWriter)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

DataSet 结构作为 XML 架构写入指定的 TextWriter 对象。

C#
public void WriteXmlSchema (System.IO.TextWriter? writer);
C#
public void WriteXmlSchema (System.IO.TextWriter writer);

参数

writer
TextWriter

要进行写入的 TextWriter 对象。

示例

以下示例创建一个 System.Text.StringBuilder 对象,该对象用于创建新的 System.IO.StringWriter。 将 StringWriter 传递到 WriteXmlSchema 方法,并将生成的字符串输出到控制台窗口。

C#
private void WriteSchemaWithStringWriter(DataSet thisDataSet)
{
    // Create a new StringBuilder object.
    System.Text.StringBuilder builder = new System.Text.StringBuilder();

    // Create the StringWriter object with the StringBuilder object.
    System.IO.StringWriter writer = new System.IO.StringWriter(builder);

    // Write the schema into the StringWriter.
    thisDataSet.WriteXmlSchema(writer);

    // Print the string to the console window.
    Console.WriteLine(writer.ToString());
}

注解

WriteXmlSchema使用 方法将 的DataSet架构写入 XML 文档。 架构包括表、关系和约束定义。 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。

XML 架构是使用 XSD 标准编写的。

若要将数据写入 XML 文档,请使用 WriteXml 方法。

派生自 类的System.IO.TextWriter类包括 、System.Web.HttpWriterSystem.CodeDom.Compiler.IndentedTextWriterSystem.Web.UI.HtmlTextWriterSystem.IO.StreamWriterSystem.IO.StringWriter

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteXmlSchema(String)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

将 XML 架构形式的 DataSet 结构写入文件。

C#
public void WriteXmlSchema (string fileName);

参数

fileName
String

要向其写入的文件的名称(包括路径)。

例外

示例

C#
private void WriteSchemaToFile(DataSet thisDataSet)
{
    // Set the file path and name. Modify this for your purposes.
    string filename="Schema.xml";

    // Write the schema to the file.
    thisDataSet.WriteXmlSchema(filename);
}

注解

WriteXmlSchema使用 方法将 的DataSet架构写入 XML 文档。 架构包括表、关系和约束定义。 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。

XML 架构是使用 XSD 标准编写的。

若要将数据写入 XML 文档,请使用 WriteXml 方法。

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteXmlSchema(XmlWriter)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

将 XML 架构形式的 DataSet 结构写入 XmlWriter 对象。

C#
public void WriteXmlSchema (System.Xml.XmlWriter? writer);
C#
public void WriteXmlSchema (System.Xml.XmlWriter writer);

参数

writer
XmlWriter

要向其中进行写入的 XmlWriter

示例

以下示例使用指定路径创建一个新 System.IO.FileStream 对象。 对象 FileStream 用于创建 XmlTextWriter 对象。 WriteXmlSchema然后,使用 XmlTextWriter 对象调用 方法,以将架构写入磁盘。

C#
private void WriteSchemaWithXmlTextWriter(DataSet thisDataSet)
{
    // Set the file path and name. Modify this for your purposes.
    string filename="SchemaDoc.xml";

    // Create a FileStream object with the file path and name.
    System.IO.FileStream stream = new System.IO.FileStream
        (filename,System.IO.FileMode.Create);

    // Create a new XmlTextWriter object with the FileStream.
    System.Xml.XmlTextWriter writer =
        new System.Xml.XmlTextWriter(stream,
        System.Text.Encoding.Unicode);

    // Write the schema into the DataSet and close the reader.
    thisDataSet.WriteXmlSchema(writer );
    writer.Close();
}

注解

WriteXmlSchema使用 方法将 的DataSet架构写入 XML 文档。 架构包括表、关系和约束定义。 若要将架构写入 XML 文档,请使用 WriteXmlSchema 方法。

XML 架构是使用 XSD 标准编写的。

若要将数据写入 XML 文档,请使用 WriteXml 方法。

System.Xml.XmlWriter 类继承的一个类是 XmlTextWriter 类。

另请参阅

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteXmlSchema(Stream, Converter<Type,String>)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

DataSet 结构作为 XML 架构写入指定的 Stream 对象。

C#
public void WriteXmlSchema (System.IO.Stream? stream, Converter<Type,string> multipleTargetConverter);
C#
public void WriteXmlSchema (System.IO.Stream stream, Converter<Type,string> multipleTargetConverter);

参数

stream
Stream

要写入到的 Stream 对象。

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteXmlSchema(TextWriter, Converter<Type,String>)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

DataSet 结构作为一个 XML 架构写入指定的 TextWriter

C#
public void WriteXmlSchema (System.IO.TextWriter? writer, Converter<Type,string> multipleTargetConverter);
C#
public void WriteXmlSchema (System.IO.TextWriter writer, Converter<Type,string> multipleTargetConverter);

参数

writer
TextWriter

要写入到的 TextWriter 对象。

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

WriteXmlSchema(XmlWriter, Converter<Type,String>)

Source:
DataSet.cs
Source:
DataSet.cs
Source:
DataSet.cs

DataSet 结构作为一个 XML 架构写入指定的 XmlWriter

C#
public void WriteXmlSchema (System.Xml.XmlWriter? writer, Converter<Type,string> multipleTargetConverter);
C#
public void WriteXmlSchema (System.Xml.XmlWriter writer, Converter<Type,string> multipleTargetConverter);

参数

writer
XmlWriter

要写入到的 XmlWriter 对象。

multipleTargetConverter
Converter<Type,String>

用于将 Type 转换为字符串的委托。

适用于

.NET 9 和其他版本
产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1