Show / Hide Table of Contents

    DataStoreDataExtensions.ImportRowFromString(this IDataStoreBase dataStore, string text, int row,DwBuffer dwBuffer = DwBuffer.Primary) Method

    .NET Standard 2.x

    Inserts a data row from a TXT string into a DataStore object.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    public static int ImportRowFromString(this IDataStoreBase dataStore, string text, int row, DwBuffer dwBuffer = DwBuffer.Primary);
    

    Parameters

    text System.String

    A string from which you want to copy the data. The string should contain tab-separated columns with one row per line.

    row System.Int32

    An Int32 value identifying the row before which you want to insert a row. To insert a row at the end, specify a negative value or a value greater than the number of rows in DataStore.

    dwbuffer DWNet.Data.DwBuffer

    The specified buffer of the DataStore.

    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 string to the DataStore.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.DataStoreDataExtensionsExamples
    {
        public class ImportRowFromStringExample
        {
            private readonly SchoolContext _context;
    
            public ImportRowFromStringExample(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);
    			
    			// Instantiates a Department object and populates it with data.
                var department = new D_Department
                {
                    Departmentid = 1,
                    Name = "Development",
                    Budget = 100,
                    Startdate = DateTime.Now,
                    Administrator = 1
                };
    			
    			// Adds the Department object to the DataStore.
                datastore.Add(department);
                Console.WriteLine("Before Import, Rowcount: {0}", datastore.RowCount);
    
                // DataStore has only one row of data.
                // Exports using the ExportString method without the columns heading.
                string str = datastore.ExportString(0, 0, false);
    
                // Output: "1\t\"Development\"\t100\t2020/4/1 10:50:33\t1\r\n"
                Console.WriteLine("ExportString: {0}", str);
    
                // Imports data from JSON to DataStore
                datastore.ImportRowFromString(str, 0, DwBuffer.Primary);
    
                Console.WriteLine("After Import, Rowcount: {0}", datastore.RowCount);
    
                /*This code produces the following output:
    
                Before Import, Rowcount: 1
                ExportString: "1\t\"Development\"\t100\t2020/4/1 10:50:33\t1\r\n"
                After Import, Rowcount: 2
               */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon