Show / Hide Table of Contents

    IModelStore<TModel>.AddRange(IEnumerable<TModel> models) Method

    .NET Standard 2.x | Current Version (1.0.1)

    0.5.0-alpha

    1.0.1 (current)

    Appends a sequence of model objects to the end of ModelStore.

    Namespace: PowerBuilder.Data

    Assembly: PowerBuilder.Data.dll

    Syntax

      public void AddRange(IEnumerable<TModel> models);
    

    Parameters

    models System.Collections.Generic.IEnumerable<TModel>

    A sequence of model objects to be added to the end of ModelStore.

    Remarks

    If ModelStore is being tracked, the newly added model objects will have the ModelState.NewModified state.

    Examples

    The following code example demonstrates how to add multiple rows (model objects) to the end of ModelStore.

    using Appeon.ApiDoc.Models.School;
    using System.Collections.Generic;
    using System;
    using PowerBuilder.Data;
    
    namespace Appeon.ApiDoc.IModelStoreExamples
    {
        public class AddRangeExample
        {
            private readonly SchoolContext _context;
    
            public AddRangeExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example()
            {
                // Create a List<Department> object and add two departments.
                var deptList = new List<Department>();
    
                var newdept = new Department()
                {
                    DepartmentID = 8001,
                    Name = "New Department",
                    Budget = 100000m,
                    StartDate = new DateTime(2019, 1, 1)
                };
                deptList.Add(newdept);
    
                var newdept2 = new Department()
                {
                    DepartmentID = 8002,
                    Name = "New Department2",
                    Budget = 200000m,
                    StartDate = new DateTime(2019, 1, 1)
                };
                deptList.Add(newdept2);
    
                // Create a new ModelStore.
                var depts = new ModelStore<Department>();
    
                // Adds the two departments to the end of ModelStore.
                depts.AddRange(deptList);
    
                Console.WriteLine("Count: {0}", depts.Count);
    
                /* This code produces the following output:
    
                Count = 2
                */
            }
        }
    }
    

    Example Refer To

    Model Class: Department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon