Show / Hide Table of Contents

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

    .NET Standard 2.x

    Returns the last index of the next row in the DataStore in which data meets the criteria defined by the predicate.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

    int FindLastIndex(Predicate<TModel> predicate);
    

    Parameters

    predicate Predicate<TModel>

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

    Returns

    System.Int

    Returns the zero-based index number of the row found.

    Returns -1 if no row is found.

    Examples

    The following code example demonstrates how to return the index number of the last department record using a Predicate object.

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStore_GenericExamples
    {
        public class FindLastIndexExample
        {
            private readonly SchoolContext _context;
    
            public FindLastIndexExample(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();
    
                // The last record in the Department table is found: 
                // departmentid=2, name=English
                var findrow = datastore.FindLastIndex(d => d.Departmentid < 3);
    
                Console.WriteLine("Department ID: {0}; Department Name: {1}",
                                   datastore.GetItem<int>(findrow, "departmentid"),
                                   datastore.GetItem<string>(findrow, "name"));
    
                /*This code produces the following output:
                 
                Department ID: 2; Department Name: English
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon