Show / Hide Table of Contents

    IModelStore<TModel>.RemoveRange(int index, int count) Method

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

    0.5.0-alpha

    1.0.1 (current)

    Removes a subset of model objects from the specified position in ModelStore.

    Namespace: PowerBuilder.Data

    Assembly: PowerBuilder.Data.dll

    Syntax

      public void RemoveRange(int index, int count);
    

    Parameters

    index System.Int32

    The zero-based index at which the range starts.

    count System.Int32

    A number specifying how many model objects (starting from the index parameter) to remove.

    Remarks

    If ModelStore is being tracked, the removed model objects will have the ModelState.Deleted state.

    Examples

    The following code example demonstrates how to remove multiple model objects from the specified position.

    using Appeon.ApiDoc.Models.School;
    using System;
    using PowerBuilder.Data;
    
    namespace Appeon.ApiDoc.IModelStoreExamples
    {
        public class RemoveRangeExample
        {
            private readonly SchoolContext _context;
    
            public RemoveRangeExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example()
            {
                var courses = new ModelStore<Course>();
    
                // Retrieves data.
                courses.Retrieve(_context);
    
                // Shows the number of model objects in ModelStore before removed
                Console.WriteLine("Before Remove Count: {0}", courses.Count);
    
                // Removes two model objects starting from row 2
                courses.RemoveRange(1, 2);
    
                // Shows the number of model objects in ModelStore after removed
                Console.WriteLine("After Remove Count: {0}", courses.Count);
    
                /* This code example produces the following output:
                
                 Before Remove Count: 12
                 After Remove Count: 10
                */
            }
        }
    }
    

    Example Refer To

    Model Class: Course

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon