Query Data in Cache with LINQPad
Note
This feature is only available in NCache Enterprise Edition.
NCache provides integration with the popular .NET utility LINQPad to query cache data.
Important
Pre-requisites to query NCache's objects in LINQPad:
- The cache data being queried must be indexed.
- LINQPad for NCache must be configured.
To start writing LINQ queries in LINQPad:
- Open up LINQPad and go to the Query tab.
- Go to Language and select C# Statement(s) from the drop down list.
- You can now write your LINQ queries over the configured cache, and see the results in the same window.
To process queries in LINQPad, NCache LINQ Provider uses the NCacheContext
class which further implements the IQueryable interface provided by .NET framework. NCacheContext
requires a valid cache name to process a query.
In the following code, it is assumed ClusteredCache contains Product objects. A Product class LINQ object is created using NCacheContext
, which is used to query the product which has ProductID == 12.
IQueryable<Product> product = new NCacheContext<Product>("myPartitionedCache");
var result = from prod in product
where prod.ProductID == 12
select prod;
result.Dump();
See Also
Search Cache with LINQ
LINQ Reference for NCache
SQL Search for Objects Syntax and Usage
Locking Data For Concurrency Control