IDataStore<TModel>.Find(Predicate<TModel> predicate, bool calcCompute, DwBuffer bufferType = DwBuffer.Primary) Method
.NET Standard 2.x
Finds the next row in the specified buffer of the DataStore in which data meets the condition specified by the expression.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
TModel Find(Predicate<TModel> predicate, bool calcCompute, DwBuffer bufferType = DwBuffer.Primary);
Parameters
predicate
Predicate<TModel>
A Predicate<TModel>
object that you want to use as the search criteria.
calcCompute
System.Boolean
Whether to calculate columns with DwCompute
attribute.
bufferType
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; and 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 calcCompute
parameters.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStore_GenericExamples
{
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_person_with_dwcompute.
var datastore = new DataStore<D_Person_With_Dwcompute>(_context);
datastore.Retrieve();
// The first record in the Department table is found:
// PersonID =1, FirstName=Kim, LastName=Abercrombie
var person = datastore.Find(d => d.Personid < 3, true, 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: 1; FirstName: Kim; LastName: Abercrombie; Compute_Fullname: Kim Abercrombie;
*/
}
}
}
Example Refer To
Model Class: D_Person_With_Dwcompute
DataWindow File: d_person_with_dwcompute