Show / Hide Table of Contents

    IDataStore.Find<TModel>(Predicate<TModel> predicate, int start, int end, DwBuffer dwBuffer = DwBuffer.Primary) Method

    .NET Standard 2.x

    Generic method. Finds the next row in the DataStore in which data meets the criteria defined by Predicate. If both start and end parameters are set to -1, it indicates the search starts from the beginning to the end. The primary buffer is specified by default.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

     TModel Find<TModel>(Predicate<TModel> predicate, int start, int end, DwBuffer dwBuffer = DwBuffer.Primary);
    

    Type Parameters

    TModel

    The type of a model class that matches with to the current DataObject.

    Parameters

    predicate System.Predicate<TModel>

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

    start System.Int32

    The zero-based index number of the row from which the search starts.

    If start is larger than end, it will do a backward search instead of forward search.

    If it is negative, it starts from 0.

    end System.Int32

    The zero-based index number of the row at which the search ends.

    If it is negative, it searches to the end.

    dwBuffer DWNet.Data.DwBuffer

    The buffer in which to find row.

    It is specified to the primary buffer by default.

    Returns

    TModel

    Returns the TModel object which contains the data for the row found.

    It returns null if no row is found.

    Examples

    The following code example demonstrates how to find the department record by a Predicate<TModel> object and using the start and end parameters.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStoreExamples
    {
        public class FindExample
        {
            private readonly SchoolContext _context;
    
            public FindExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example2()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore("d_department", _context);
    
                datastore.Retrieve();
    
                // The first record in the Department table is found: 
                // departmentid =1, name=Engineering
                var department = datastore.Find<D_Department>("departmentid < 3");
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   department.Departmentid,
                                   department.Name);
    
                // The second record in the Department table is found: 
                // departmentid =2, name=English
                // 1 indicates to find from the second row, -1 indicates to find through the end.
                department = datastore.Find<D_Department>(d => d.Departmentid < 3, 1, -1);
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   department.Departmentid,
                                   department.Name);
    
    
                /*This code produces the following output:
                 
                Department ID: 1; Department Name: Engineering
                Department ID: 2; Department Name: English
                */
    
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon