Try Playground
Show / Hide Table of Contents

Method ExecuteReader

ExecuteReader(QueryCommand, Boolean, Int32)

Performs search on the cache based on the query specified. Returns list of key-value pairs in a data reader which fulfills the query criteria. This key-value pair has cache key and its respective value. You can specify the flag for specifying if you want data with keys.

Declaration
ICacheReader ExecuteReader(QueryCommand queryCommand, bool getData = true, int chunkSize = -1)
Parameters
Type Name Description
QueryCommand queryCommand

QueryCommand containing query text and values.

System.Boolean getData

Flag to indicate whether the resulting values have to be returned with keys or not.

System.Int32 chunkSize

Size of data/keys packets received after search, default value is 512*1024 KB.

Returns
Type Description
ICacheReader

Reads forward-only stream of result sets of the query executed on cache.

Remarks

These operators are supported by NCache Queries.

  1. Comparison Operators = , == , != , <> , < , > , <=, >=, IN
  2. Logical Operators AND , OR , NOT
  3. Miscellaneous () , DateTime.Now , DateTime("any date time compatible string")
Examples
ICache cache = CacheManager.GetCache("demoCache");

Instead of Product, specify fully qualified name of your custom class.

string query = "SELECT Product where this.ProductName = ?";

QueryCommand queryCommand = new QueryCommand(query);
queryCommand.Parameters.Add("ProductName", "Chai");
queryCommand.Parameters.Add("UnitsInStock", 250);

try
{
    ICacheReader reader = cache.SearchService.ExecuteReader(queryCommand, true, 50);
    if (reader.FieldCount > 0)
    {
        while (reader.Read())
        {
            object category = reader.GetValue<object>(0);
            //perform operations
        }
    }
    else
    {
        //perform operations
    }
    reader.Close();
}

catch
{
    //handle exception
}
In This Article
  • ExecuteReader(QueryCommand, Boolean, Int32)

Contact Us

PHONE

+1 (214) 764-6933   (US)

+44 20 7993 8327   (UK)

 
EMAIL

sales@alachisoft.com

support@alachisoft.com

NCache
  • NCache Enterprise
  • NCache Professional
  • Edition Comparison
  • NCache Architecture
  • Benchmarks
Download
Pricing
Try Playground

Deployments
  • Cloud (SaaS & Software)
  • On-Premises
  • Kubernetes
  • Docker
Technical Use Cases
  • ASP.NET Sessions
  • ASP.NET Core Sessions
  • Pub/Sub Messaging
  • Real-Time ASP.NET SignalR
  • Internet of Things (IoT)
  • NoSQL Database
  • Stream Processing
  • Microservices
Resources
  • Magazine Articles
  • Third-Party Articles
  • Articles
  • Videos
  • Whitepapers
  • Shows
  • Talks
  • Blogs
  • Docs
Customer Case Studies
  • Testimonials
  • Customers
Support
  • Schedule a Demo
  • Forum (Google Groups)
  • Tips
Company
  • Leadership
  • Partners
  • News
  • Events
  • Careers
Contact Us

  • EnglishChinese (Simplified)FrenchGermanItalianJapaneseKoreanPortugueseSpanish

  • Contact Us
  •  
  • Sitemap
  •  
  • Terms of Use
  •  
  • Privacy Policy
� Copyright Alachisoft 2002 - 2025. All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top