Documentation
SolutionDeveloperComplianceProjects
  • Getting Started
  • Technology
    • Application Framework
    • Object-Relational Mapping
    • Security Framework
    • Architecture Pattern
    • API Management
  • Environment
    • Development Tool
    • Database Server
    • Web Server
  • PRESENTATION
    • Design Material
    • HTML Helpers
    • Icon Images
    • Custom CSS
    • JQuery Plugin
      • DataTables
      • Tabs
      • Date Picker
      • Calendar
      • Chart
      • Treeview
    • Client Script
      • Open Modal
      • Close Modal
      • Handle return data
      • Load Content
      • Change Hash
      • Change Title
      • Get actual Hash
      • Get Content
      • Update Content
      • Delete Content
      • Get Partial Content
      • Get Partial Content Async
      • Update Partial Content
      • Update Partial Content Async
      • Delete Partial Content
      • Get Action
      • Update Action
      • Delete Action
      • Cascading Dropdown
      • Display Document
    • MVC View
  • BACKEND
    • Base Controller
    • Controller
    • Base Model
    • View Model
    • Class Utility
      • Constant Values
      • Global Properties
      • Option Helper
      • Setting Helper
    • Data Repository
      • Read Columns
      • Read All Columns
      • Read First Record
      • Read by Primary Key
      • Find Record
      • Insert Record
      • Update Record
      • Delete Entity
      • Delete by Criteria
      • Delete by Primary Key
      • Counting Record
      • Check Exist
      • Generate Row-Id
    • Unit Of Work
    • Data Entity
  • Application Features
    • Account Management
    • Navigation Editor
    • Access Control
  • Examples
    • Simple Page
    • Master Detail
    • Editor Template
Powered by GitBook
On this page
  • Syntax
  • Arguments
  • Description
  • Example
  • Example 1: Counting records by only one criterion
  • Example 2: Filtering records by multiple criteria
  1. BACKEND
  2. Data Repository

Check Exist

Syntax

Exists(filter);

Arguments

filter

Expression<Func<T, bool>>

Criteria by which the records of the repository should be filtered.

This parameter must not be empty.

null

Description

Checks if repository contains any record that fulfills the criteria specified in the parameter filter. If there is at least one record that fulfills the criteria, it will return "true", else it will return "false".

Example

Example 1: Counting records by only one criterion

The following program illustrates the function call with only one criterion:

var isExist = repo.Exists(x => x.ProductID == "ADAM-800-BTO");

Function will check if repository contains any record that has "ADAM-567-BTO" as Production ID. If there is at least 1 record, then it will store the boolean value "true" into the variable isExist, else it will store the boolean value "false".

Example 2: Filtering records by multiple criteria

The following program illustrates the function call with multiple criteria:

var isExist = repo.Exists(x => x.ProductID == "ADAM-800-BTO"
                            && x.Quantity > 10 
                            && x.IsUrgent == true);

Function will check if repository contains any record that has "ADAM-567-BTO" as Production ID, has a Quantity of more than 10 and is Urgent. If there is at least 1 record that fulfills all the criteria, then it will store the boolean value "true" into the variable isExist, else it will store the boolean value "false".

PreviousCounting RecordNextGenerate Row-Id

Last updated 2 years ago