Show / Hide Table of Contents

    IDataPacker.AddDataTable([NotNull]this IDataPacker packer,[NotNull]string key, [NotNull]DataTable value) Method

    .NET Standard 2.x

    Add a DataTable object as an element to the IDataPacker object.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public static void AddDataTable(
    [NotNull]this IDataPacker packer,
    [NotNull]string key,
    [NotNull]DataTable value)
    

    Parameters

    key System.String

    The key for the element, which is the identifier of the element in the IDataPacker object.

    value System.Data.DataTable

    A DataTable object, which is the value of the element to be added to the IDataPacker object.

    Examples

    The following code example adds a DataTable object as an element to the IDataPacker object and uses the DataTable name as the key name for the element.

    using SnapObjects.Data;
    using System;
    using System.Data;
    
    namespace Appeon.ApiDoc.IDataPackerExamples
    {
        public class AddDataTableExample
        {
            private readonly SchoolContext _context;
    
            public AddDataTableExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
    
            public void Example1()
            {
                var packer = new DataPacker();
    
                var dataTable = new DataTable();
    
                // Adds the dataTable object as an element to the current IDataPacker
                // and adds the dataTable name as the key name for the element
                var key = nameof(dataTable);
                packer.AddDataTable(key, dataTable);
    
                // Gets and shows the number of elements in the current IDataPacker
                Console.WriteLine("The element count: {0}", packer.Count.ToString());
    
                /* This code example produces the following output:
                
                The element count: 1
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon