Show / Hide Table of Contents

    IDataStore.Filter(string format) Method

    .NET Standard 2.x

    Filters rows by the current filter criteria. Rows that do not meet the filter criteria are moved to the filter buffer. The filter criteria can be re-set using the format parameter.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public bool Filter(string format);
    

    Parameters

    format System.String

    (Optional) A string whose value is a Boolean expression that you want to use as the filter criteria. The expression includes column names or numbers. A column number must be preceded by a pound sign (#).

    Returns

    System.Boolean

    Returns true if it succeeds.

    Remarks

    When the format parameter is not specified, the Filter method uses the current filter criteria for the DataStore. To change the filter criteria, use the SetFilter method. If you do not call SetFilter to assign or change criteria before calling the Filter method, the DataStore will default to use the criteria in the DataWindow object definition.

    When the Retrieve method retrieves data for the DataStore, it applies the filter that was defined for the DataWindow object, if any. You only need to call Filter after you change the filter criteria with SetFilter or if the data has changed because of processing or user input.

    Examples

    The following code example demonstrates how to use the Filter method to filter the data and reset the filter criteria.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class FilterExample
        {
            private readonly SchoolContext _context;
    
            public FilterExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example1()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore("d_department", _context);
    
                datastore.Retrieve();
    
                // Sets the filter criteria to 'departmentid < 3'.
                datastore.Filter("departmentid < 3");
    
                Console.WriteLine("datastore.RowCount: {0}",
                    datastore.RowCount);
    
                // Resets the filter criteria via the format argument.
                datastore.Filter("departmentid < 5");
    
                // There are 3 records that meet the criteria
                Console.WriteLine("datastore.RowCount: {0}",
                   datastore.RowCount);
    
                /*This code produces the following output:
                 
                datastore.RowCount: 2
                datastore.RowCount: 3 
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon