IDataStoreBase.GetDataImporter(DataFormat dataFormat) Method
.NET Standard 2.x
Gets the DataStore importer, you need to specify the data import format (DataFormat
).
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
IDwDataImporter GetDataImporter(DataFormat dataFormat);
Parameters
dataFormat
SnapObjects.Data.DataFormat
Format of the imported data.
Returns
DWNet.Data.IDwDataImporter
DataStore data importer.
Examples
The following code example demonstrates how to get DataStore importer in the specified format.
using DWNet.Data;
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class GetDataImporterExample
{
private readonly SchoolContext _context;
public GetDataImporterExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
var datastore2 = new DataStore("d_department", _context);
datastore.Retrieve();
// Gets DataStore exporter in JSON format
var exporter = datastore.GetDataExporter(DataFormat.Json);
// Exports the first row of DataStore.
string exportRow_json = exporter.ExportRow(0);
Console.WriteLine("ExportRow Json:{0}", exportRow_json);
// Gets DataStore importer in JSON format
var importer = datastore2.GetDataImporter(DataFormat.Json);
// The first entry to import data into the DataStore
int count = importer.ImportRow(exportRow_json, 0);
Console.WriteLine("Import Count:{0}, DataStore Count:{1}", count, datastore2.RowCount);
// Gets DataStore exporter in XML format
exporter = datastore.GetDataExporter(DataFormat.Xml);
string xml = exporter.Export();
// Gets DataStore importer in XML format
importer = datastore2.GetDataImporter(DataFormat.Xml);
count = importer.Import(xml);
Console.WriteLine("Import Count:{0}, DataStore Count:{1}", count, datastore2.RowCount);
/*This code produces the following output:
ExportRow Json: {"Departmentid":1,"Name":"Engineering","Budget":350000.0000,"Startdate":"2007-09-01T00:00:00","Administrator":2}
Import Count:1, DataStore Count:1
Import Count:4, DataStore Count:5
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x