Show / Hide Table of Contents

    IDataStore.Exists<TModel>(Predicate<TModel> 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

      public bool Exists<TModel>(Predicate<TModel> predicate);
    

    Type Parameters

    TModel

    The type of a model class that matches with the current DataObject.

    Parameters

    predicate System.Predicate<TModel>

    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 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.IDataStoreExamples
    {
        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<D_Department>(
                    a => a.Name == "Department New");
    
                Console.WriteLine("Department New: {0}", exists);
    
                // There is a record in datastore whose Name="Engineering"
                exists = datastore.Exists<D_Department>(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

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon