Try Playground
Show / Hide Table of Contents

Language Integrated Query Reference

NCache supports both Query and Lambda execution for LINQ (Language Integrated Query). This page provides sample queries for supported operators for each execution type.

First, keep in mind that the following are not currently supported by NCache LINQ (Language Integrated Query) Provider:

  • Nested queries
  • ORDER BY operator
  • GROUP BY operator
  • JOIN operator

The syntax will usually appear as follows:

FROM [Object] IN [List]
WHERE [Condition]
SELECT [Object]

The following examples assume a Product class object that contains ProductID, ProductName, and Category attributes. Note that the examples in Query expressions are alternative to Lambda expression queries, and vice versa.

Supported Projection Operators for Language Integrated Query

The following are the supported Projection Operators for Language Integrated Query.

Operator(s) Examples
select Query: from product in products select product;
Lambda: products.Select(p => p);

Restriction Operators

The following are the supported Restriction Operators for Language Integrated Query.

Operator(s) Examples
where Query: from product in products where product.ProductID == 1001 select product;
Lambda: products.Where(p => p.ProductID == 1001);

Basic Query Operators

The following are the supported Basic Query Operators for Language Integrated Query.

Operator(s) Examples
== Query: from product in products where product.ProductID == 1001 select product;
Lambda: products.Select(p => p).Where(p => p.ProductID == 1001);
!= Query: from product in products where product.ProductID != 1001 select product;
Lambda: products.Select(p => p).Where(p => p.ProductID != 1001);
< Query: from product in products where product.ProductID < 1001 select product;
Lambda: products.Select(p => p).Where(p => p.ProductID < 1001);
> Query: from product in products where product.ProductID > 1001 select product;
Lambda: products.Select(p => p).Where(p => p.ProductID > 1001);
<= Query: from product in products where product.ProductID <= 1001 select product;
Lambda: products.Select(p => p).Where(p => p.ProductID <= 1001);
>= Query: from product in products where product.ProductID >= 1001 select product;
Lambda: products.Select(p => p).Where(p => p.ProductID >= 1001);

Logical Operators

The following are the supported Logical Operators for Language Integrated Query.

Operator(s) Examples
&& Query: from product in products where product.ProductID >= 1001 && product.ProductName == "Chai" select product;
Lambda: products.Select(p => p).Where(p => p.ProductID >= 1001 && p.ProductName == "Chai");
|| Query: from product in products where product.ProductID == 1001 || product.ProductName == "Chai" select product;
Lambda: products.Select(p => p).Where(p => p.ProductID >= 1001 || p.ProductName == "Chai");

Aggregation Operators

The following are the supported Aggregation Operators for Language Integrated Query.

Operator(s) Examples
Count Query: (from product in products where product.Category == "Beverages" select product).Count();
Lambda: products.Select(p => p).Where(p => p.Category == "Beverages").Count();
Max Query: (from product in products where product.Category == "Beverages" select product.ProductID).Max();
Lambda: products.Where(p => p.Category == "Beverages").Max(p => p.ProductID);
Min Query: (from product in products where product.Category == "Beverages" select product.ProductID).Min();
Lambda: products.Where(p => p.Category == "Beverages").Min(p => p.ProductID);
Average Query: (from product in products where product.ProductID < 1010 select product.ProductID).Average();
Lambda: products.Where(p => p.ProductID > 1001).Average(p => p.ProductID);
Sum Query: (from product in products where product.ProductID <= 1010 select product.ProductID).Sum();
Lambda: products.Where(p => p.ProductID > 1001).Sum(p => p.ProductID);

Wildcard Operators

The following are the supported Wildcard Operators for Language Integrated Query.

Operator(s) Example
StartsWith Query: from product in products where product.Category.StartsWith("Be") select product;
Lambda: products.Select(p => p).Where(p => p.Category.StartsWith("Be"));
EndsWith Query: from product in products where product.Category.EndsWith("ages") select product;
Lambda: products.Select(p => p).Where(p => p.Category.EndsWith("ages"));
Contains Query: from product in products where product.Category.Contains("Bever") select product;
Lambda: products.Select(p => p).Where(p => p.Category.Contains("Bever"));
Equals Query: from product in products where product.Category.Equals("Beverages") select product;
Lambda: products.Select(p => p).Where(p => p.Category.Equals("Beverages"));

See Also

.NET: Alachisoft.NCache.Linq namespace.

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 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.
Back to top