Show / Hide Table of Contents

    DwTemplateExporter.Export(object dataSource, IDataTemplate template) Method

    .NET Standard 2.x

    Exports data from the DataStore using DataTemplate.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    public static string Export(object datastore, IDataTemplate template)
    

    Parameters

    dataSource System.Object

    An object specifying the data source.

    template SnapObjects.Data.IDataTemplate

    A formatted data template for populating data.

    Returns

    System.String

    Data string in the template format.

    Examples

    The following code example demonstrates how to use the Export method.

    using DWNet.Data;
    
    namespace Appeon.ApiDoc.DwTemplateExporterExamples
    {
        public class ExportExample
        {
            private readonly SchoolContext _context;
    
            public ExportExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example()
            {
                // Instantiates datastore with datawindow: d_department
                var datastore = new DataStore("d_department", _context);
    
                datastore.Retrieve();
    
                // Get the template of the d_department class.
                var dataTemplate = datastore.GetTemplate("xml_default");
    
                string xml = DwTemplateExporter.Export(datastore, dataTemplate);
    
                /*The exported JSON file is:
    
                Export.xml
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon