Show / Hide Table of Contents

    IDwDataImporter.ImportRow(string text, int row, DwBuffer dwBuffer = DwBuffer.Primary) Method

    .NET Standard 2.x

    Import one row data into the specified buffer of DataStore with the specified DataFormat based on the key name.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    int ImportRow(string text, int row, DwBuffer dwBuffer = DwBuffer.Primary);
    

    Parameters

    text System.String

    Data string in the specified format.

    The JSON string must comply with the plain-format JSON or DataWindow JSON.

    row System.Int32

    The zero-based number of the first row in the string that you want to import.

    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 JSON: Imports the JSON data to the specified buffer.

    For DataWindow JSON: Imports data from the specified buffer from the JSON string to the corresponding buffer.

    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 data from a JSON string to the DataStore.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using Newtonsoft.Json;
    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDwDataImporterExamples
    {
        public class ImportRowExample
        {
            private readonly SchoolContext _context;
    
            public ImportRowExample(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);
    
                Console.WriteLine("Before Import, Rowcount: {0}", datastore.RowCount);
    
                var department = new D_Department
                {
                    Departmentid = 1,
                    Name = "Development",
                    Budget = 100,
                    Startdate = DateTime.Now,
                    Administrator = 1
                };
    
                // Serialize Model into json data.
                string json = JsonConvert.SerializeObject(department);
    
                // Get DataStore importer in JSON format.
                var importer = datastore.GetDataImporter(DataFormat.Json);
    
                // Imports data from JSON to DataStore
                importer.ImportRow(json, 0, DwBuffer.Primary);
    
                Console.WriteLine("After Import, Rowcount: {0}", datastore.RowCount);
    
                /*This code produces the following output:
    
                Before Import, Rowcount: 0
                After Import, Rowcount: 1
               */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon