Querying NCache Data in LINQPad
NCache provides integration with the popular .NET utility LINQPad to query cache data. LINQPad is a software utility often used to interactively query SQL databases using LINQ and lambda expressions, as well as to interactively write C# without the need for an IDE. NCache provides its own provider to support LINQ queries in LINQPad for better data analysis and ease of use.
Make sure that the cache data being queried is indexed. See Configuring Query Indexes for detail.
To query over NCache’s indexed objects, you need to add reference of your assembly in LINQPad. Please follow the steps in Configuring LINQPad for NCache to add reference of your assembly.
On the Query tab, go to Language and select C# Statement(s) from the drop down list.
NCache LINQ Provider uses NCacheContext
class to process queries. The following
code shows how to implement the NCacheContext
class which further
implements IQueryable
interface. The code also shows the LINQ query based on
NCache Query Language running on cached data. NCacheContext
requires a valid
cache ID to process a query.
IQueryable<Product> product = new NCacheContext<Product>("ClusteredCache");
var result = from prod in product
where prod.ProductID == 12
select prod;
result.Dump();