Show / Hide Table of Contents

    IDataStore<TModel>.Exists(Predicate<TModel> predicate, DwBuffer bufferType = DwBuffer.Primary) 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 Exists(Predicate<TModel> predicate, DwBuffer bufferType = DwBuffer.Primary);
    

    Parameters

    predicate Predicate<TModel>

    A Predicate<TModel> object that you want to use as the search criteria.

    bufferType DWNet.Data.DwBuffer

    The buffer in which to find row.

    It is specified to the primary buffer by default.

    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 Exists 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 ExistsExample
        {
            private readonly SchoolContext _context;
    
            public ExistsExample(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();
                
                // No record in datastore whose Name="Department New"
                bool exists = datastore.Exists(a => a.Name == "Department New");
    
                Console.WriteLine("Department New: {0}", exists);
    
                // There is a record in datastore whose Name="Engineering"
                exists = datastore.Exists(a => a.Name == "Engineering");
                Console.WriteLine("Engineering: {0}", exists);
    
                /*This code produces the following output:
                
                Department New: False
                Engineering: True    
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Back to top Generated by Appeon