Show / Hide Table of Contents

    IDataStore<TModel>.RemoveAll(Predicate<TModel> predicate) Method

    .NET Standard 2.x

    Removes rows that meet the specified conditions from the primary buffer of the DataStore.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    int RemoveAll(Predicate<TModel> predicate);
    

    Parameters

    predicate Predicate<TModel>

    A Predicate<TModel> object that you want to use as the search criteria.

    Returns

    System.Int32

    Number of successful rows removed.

    Examples

    The following code example demonstrates how to remove the data item according to the specified TModel.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStore_GenericExamples
    {
        public class RemoveAllExample
        {
            private readonly SchoolContext _context;
    
            public RemoveAllExample(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);
    
                datastore.Retrieve();
    
                Console.WriteLine("Before Remove, Rowcount: {0}", datastore.RowCount);
    
                // Removes the data item
                datastore.RemoveAll(a => a.Departmentid == 1);
    
                Console.WriteLine("After Remove, Rowcount: {0}", datastore.RowCount);
    
                /*This code produces the following output:
                 
                Before Remove, Rowcount: 4
                After Remove, Rowcount: 3
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon