DataStoreDataExtensions.ExportXml(this IDataStoreBase dataStore, MappingMethod mappingMethod) Method
.NET Standard 2.x
Exports data from the DataStore primary buffer to a DataWindow XML string.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public static string ExportXml(this IDataStoreBase dataStore, MappingMethod mappingMethod);
Parameters
mappingMethod
SnapObjects.Data.MappingMethod
A value of the MappingMethod
enumerated datatype specifying the method for mapping columns.
MappingMethod.Index
-- Use the index of XML item to map with the DataStore column. The "mapping-method" value in the exported XML string is 0.MappingMethod.ColumnIndex
-- Use the index of meta-columns to map with the DataStore column. The "mapping-method" value in the exported XML string is 1.MappingMethod.Key
-- Use the key of XML item to map with the DataStore column. The "mapping-method" value in the exported XML string is 2.
Returns
System.String
Returns the XML string.
Examples
The following code example demonstrates how to export the department records to an XML string using different mapping methods.
using SnapObjects.Data;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.DataStoreDataExtensionsExamples
{
public class ExportXmlExample
{
private readonly SchoolContext _context;
public ExportXmlExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example1()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
// Generates data in primary/delete/filter buffers for this example
datastore.Retrieve();
datastore.DeleteRow(0);
datastore.SetFilter("departmentid < 5");
datastore.Filter();
// Exports data from primary buffer to XML string
// mapped by the XML index
// mapping-method value in XML is 0
string xml1 = datastore.ExportXml(MappingMethod.Index);
Console.WriteLine(xml1);
/*The exported XML file is:
ExportXml1_Index.xml
*/
// Exports data from primary buffer to XML string
// mapped by the XML key
// mapping-method value in XML is 2
string xml2 = datastore.ExportXml(MappingMethod.Key);
Console.WriteLine(xml2);
/*The exported XML file is:
ExportXml1_Key.xml
*/
// Exports data from primary buffer to XML string
// mapped by the column index
// mapping-method value in XML is 1
string xml3 = datastore.ExportXml(MappingMethod.ColumnIndex);
Console.WriteLine(xml3);
/*The exported XML file is:
ExportXml1_ColumnIndex.xml
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x