IDataStore<TModel>.Any(Func<TModel, bool> predicate) Method
.NET Standard 2.x
Determines whether there is a row in the primary buffer of the DataStore that meets the specified condition.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
bool Any(Func<TModel, bool> predicate);
Parameters
predicate Func<TModel, bool>
The Predicate<TModel> that defines the condition.
Returns
System.Boolean
Returns true if there is a row in the primary buffer that meets the specified condition, otherwise, false.
Examples
The following code example demonstrates how to use the Any method to determine whether there are records in the DataStore that meet the criteria.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStore_GenericExamples
{
public class AnyExample
{
private readonly SchoolContext _context;
public AnyExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Instantiates a DataStore object with datawindow object: d_department.
var datastore = new DataStore<D_Department>(_context);
datastore.Retrieve();
// No record in datastore (Name="Department New")
bool any = datastore.Any(a => a.Name == "Department New");
Console.WriteLine("Department New: {0}", any);
// There is a record in datastore whose Name="Engineering"
any = datastore.Any(a => a.Name == "Engineering");
Console.WriteLine("Engineering: {0}", any);
/*This code produces the following output:
Department New: False
Engineering: True
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department