IDataStore.Filter<TModel>(Func<TModel, bool> predicate) Method
.NET Standard 2.x
Filters rows by the filter criteria specified by a Func<TModel>
. Rows that do not meet the filter criteria are moved to the filter buffer.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool Filter<TModel>(Func<TModel, bool> predicate);
Type Parameters
TModel
The type of a model
class that matches with the current DataObject
.
Parameters
predicate
System.Func<TModel, bool>
A Func<TModel, bool>
which specifies the filter criteria.
Returns
System.Boolean
Returns true
if it succeeds.
Examples
The following code example demonstrates how to filter the department records using a Func<TModel>
object.
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 Example2()
{
// Instantiates a DataStore object with datawindow: d_department.
var datastore = new DataStore("d_department", _context);
datastore.Retrieve();
// There are 2 records in the Department table whose departmentid
// is less than 3.
datastore.Filter<D_Department>(d => d.Departmentid < 3);
Console.WriteLine("datastore.RowCount: {0}",
datastore.RowCount);
/*This code produces the following output:
datastore.RowCount: 2
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x