Query Data in Cache with LINQPad
This feature is only available in NCache Enterprise Edition.
NCache provides integration with the popular .NET utility LINQPad to query cache data.
Pre-requisites to query NCache's objects in LINQPad:
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 the .NET framework.
NCacheContext requires a valid cache name to process a query.
In the following code, it is assumed that ClusteredCache contains Product objects. A Product class LINQ object is created using
NCacheContext, which is used to query the product that has ProductID == 12.
IQueryable<Product> product = new NCacheContext<Product>("ClusteredCache"); var result = from prod in product where prod.ProductID == 12 select prod; result.Dump();