IDataStore<TModel>.FindLast(Predicate<TModel> predicate, DwBuffer bufferType = DwBuffer.Primary) Method
.NET Standard 2.x
Returns the index of the last row in the DataStore in which data meets the criteria defined by the predicate.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
TModel FindLast(Predicate<TModel> predicate, DwBuffer bufferType = DwBuffer.Primary);
Parameters
predicate
Predicate<TModel>
A Predicate<TModel>
that you want to use as the search criteria.
bufferType
DWNet.Data.DwBuffer
The buffer in which to find the row.
It is specified to the primary buffer by default.
Returns
TModel
Returns the TModel
object which contains the data for the row found; and returns null
if no row is found.
Examples
The following code example demonstrates how to find the department record by Predicate<TModel>
object.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStore_GenericExamples
{
public class FindLastExample
{
private readonly SchoolContext _context;
public FindLastExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example1()
{
// Instantiates a DataStore object with datawindow: d_person_with_dwcompute.
var datastore = new DataStore<D_Person_With_Dwcompute>(_context);
datastore.Retrieve();
// The last record in the Department table is found:
// PersonID =2, FirstName=Gytis, LastName=Barzdukas
var person = datastore.FindLast(d => d.Personid < 3, DwBuffer.Primary);
Console.WriteLine(
"PersonID ID: {0}; FirstName: {1}; LastName: {2}; Compute_Fullname: {3};",
person.Personid, person.Firstname, person.Lastname, person.Compute_Fullname);
/*This code produces the following output:
PersonID ID: 2; FirstName: Gytis; LastName: Barzdukas; Compute_Fullname: null;
*/
}
}
}
Example Refer To
Model Class: D_Person_With_Dwcompute
DataWindow File: d_person_with_dwcompute