Show / Hide Table of Contents

    IDataPacker.AddModelEntries<TModel>([NotNull]this IDataPacker packer, [NotNull]string key, [NotNull]IEnumerable<IModelEntry<TModel>> modelEntries) Method

    .NET Standard 2.x

    Adds an IEnumerable<IModelEntry<TModel>> object as an element to the IDataPacker object.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public static void AddModelEntries<TModel>(
    [NotNull]this IDataPacker packer,
    [NotNull]string key,
    [NotNull]IEnumerable<IModelEntry<TModel>> modelEntries)
    

    Parameters

    key System.String

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

    value System.Collections.Generic.IEnumerable<IModelEntry<TModel>>

    The IEnumerable<IModelEntry<TModel>> object, which is the value of the element to be added to the IDataPacker object.

    Examples

    The following code example adds a list of IModelEntry<Course> objects to the IDataPacker object and gets the number of elements in IDataPacker.

    using Appeon.ApiDoc.Models.School;
    using SnapObjects.Data;
    using System;
    using System.Collections.Generic;
    using System.Data;
    
    namespace Appeon.ApiDoc.IDataPackerExamples
    {
        public class AddModelEntriesExample
        {
            private readonly SchoolContext _context;
    
            public AddModelEntriesExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
    
            public void Example(IList<IModelEntry<Course>> courses)
            {
                var packer = new DataPacker();
    
                // Adds the list to the IDataPacker object
                packer.AddModelEntries("Models", courses);
            }
        }
    }
    

    Example Refer To

    Model Class: Course

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon