DataStoreDataExtensions.ImportXml(this IDataStoreBase dataStore, string text, DwBuffer dwbuffer, int startRow, int endRow, int startColumn, int endColumn, int dwStartColumn) Method
.NET Standard 2.x
Inserts data from an XML string into the specified buffer of DataStore. You can specify the starting and ending positions in the XML array, and specify the number of the first key value and the number of the last key value in the XML object to be imported. You can also specify the number of the first column in the DataStore that should receive data.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public static int ImportXml(this IDataStoreBase dataStore, string text, DwBuffer dwbuffer, int startRow, int endRow, int startColumn, int endColumn, int dwStartColumn);
Parameters
text
System.String
A string specifying the XML data.
The XML string must comply with the plain-format XML or DataWindow XML.
dwbuffer
DWNet.Data.DwBuffer
The specified buffer of the DataStore.
A value of the DwBuffer
enumerated datatype identifying the DataWindow buffer
into which you want to import the data.
For plain-format XML: Imports the XML data to the specified buffer.
For DataWindow XML: Imports data from the specified buffer from the XML string to the corresponding buffer.
startRow
System.Int32
The zero-based number of the first detail object in the XML array that you want to import. If it is negative, 0
is used.
endRow
System.Int32
The zero-based number of the last detail object in the XML array that you want to import. If it is negative, it indicates the rest of rows.
startColumn
System.Int32
The zero-based number of the first key value in the XML object that you want to import. If it is negative, 0
is used.
endColumn
System.Int32
The zero-based number of the last key value in the XML object that you want to import. If it is negative, it indicates the rest of columns.
Returns
System.Int32
Returns the number of rows that were imported if it succeeds.
Examples
The following code example demonstrates how to import the department records from a string to a DataStore using the dwStartColumn
parameter.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.DataStoreDataExtensionsExamples
{
public class ImportXmlExample
{
private readonly SchoolContext _context;
public ImportXmlExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example7()
{
// Instantiates the datastore with datawindow: d_department
var datastore = new DataStore("d_department", _context);
// Gets the XML string to be imported.
string importXml = GetImportXml();
// Imports data in the first and second rows of the string to the datastore
// Imports data in columns (from 2nd to 6th) of the string to the datastore
// DataStore d_department receives data beginning in the second column.
// The first column (departmentid) in DataStore has no data imported.
datastore.ImportXml(importXml, DwBuffer.Primary, 0, 1, 1, 5, 1);
Console.WriteLine("Rowcount: {0}", datastore.RowCount);
for (int row = 0, rowcount = datastore.RowCount; row < rowcount; row++)
{
Console.WriteLine("DepartmentID: {0}; Name: {1}; Budget: {2}",
datastore.GetItem<int>(row, "departmentid"),
datastore.GetItem<string>(row, "name"),
datastore.GetItem<decimal>(row, "budget"));
}
/*This code produces the following output:
Rowcount: 2
DepartmentID: 0; Name: Engineering; Budget: 220000.0000
DepartmentID: 0; Name: English; Budget: 120000.0000
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x