IDataStore.FilterEx<TModel>(Expression<Func<TModel>> expression) Method
.NET Standard 2.x
Generic method. Filters rows by the criteria specified by an Expression<Func<TModel, bool>> object. Rows that do not meet the criteria are moved to the filter buffer.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool FilterEx<TModel>(Expression<Func<TModel, bool>> expression);
Type Parameters
TModel
The type of a model class that matches with the current DataObject.
Parameters
expression System.Linq.Expressions.Expression<System.Func<TModel, bool>>
An Expression<Func<TModel, bool>> object 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 whose department ID is less than 3.
using Appeon.ApiDoc.Models;
using SnapObjects.Commons;
using DWNet.Data;
using System;
using System.Linq.Expressions;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class FilterExExample
{
private readonly SchoolContext _context;
public FilterExExample(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();
// There are 2 records in the Department table whose departmentid is
// less than 3.
datastore.FilterEx<D_Department>(d => d.Departmentid < 3);
Console.WriteLine("datastore.RowCount:");
Console.WriteLine(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