IDataStoreBase.GetTemplate(string templateName, DataFormat dataFormat = DataFormat.Xml) Method
.NET Standard 2.x
Specifies the name and format to get the template for DataStore data export.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
IDataTemplate GetTemplate(string templateName, DataFormat dataFormat = DataFormat.Xml);
Parameters
tempalteName
System.String
The name of the template that conforms to the specified syntax format.
dataFormat
SnapObjects.Data.DataFormat
DataStore data export format.
Returns
SnapObjects.Data.IDataTemplate
The specified format template.
Examples
Gets the default xml format template for DataStore data export.
using DWNet.Data;
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class GetTemplateExample
{
private readonly SchoolContext _context;
public GetTemplateExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example2()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
datastore.Retrieve();
// Specifies the name to get the template for DataStore data export.
var template = datastore.GetTemplate("xml_default");
var xml = TemplateExporter.Export(datastore, template);
Console.WriteLine("Template Content:{0}", template.Content);
Console.WriteLine("Xml:{0}", xml);
/*This code produces the following output:
Template Content:
<?xml version="1.0" encoding="UTF-16LE" standalone="no"?>
<d_department>
@foreach
{
<d_department_row>
<departmentid>@(departmentid)</departmentid>
<name att1="@(name)">@(name)</name>
<budget>@(budget)</budget>
<startdate>@(startdate)</startdate>
<administrator>@(administrator)</administrator>
</d_department_row>
}
</d_department>
Xml:
<?xml version="1.0" encoding="UTF-16LE" standalone="no"?>
<d_department>
<d_department_row>
<departmentid>1</departmentid>
<name att1="Engineering">Engineering</name>
<budget>350000.0000</budget>
<startdate>2007-09-01T00:00:00</startdate>
<administrator>2</administrator>
</d_department_row>
......
</d_department>
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x