Configure LINQPad for NCache
This feature is only available in NCache Enterprise Edition.
NCache offers seamless integration with LINQPad, a .NET 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.
NCache integration with LINQPad is quite simple as it requires just adding a reference to the NCache LINQPad provider and the custom objects that you have stored in NCache. The objects being queried must be indexed in NCache.
The following section has been implemented using LINQPad 5.
To configure LINQPad for NCache querying, follow the steps given below:
Step 1: Refer NuGet Package
Open up LINQPad and go to File -> New Query or Press Ctrl + N.
On Query menu, click Reference and Properties or press F4 to add reference. Query Properties wizard pops up.
- In Additional References tab, click on the Add NuGet… button to go to LINQPad NuGet Manager.
- In the search bar, type and search for LinqPad.NCache package. Click on the Add to Query button to install LinqPad.NCache NuGet package.
When you install LinqPad.NCache, it automatically installs Linq.NCache NuGet package as a dependency.
- Click Close to exit LINQPad NuGet Manager.
Step 2: Refer Assembly for Searchable Attributes
Once you have successfully installed NCache NuGet packages for LINQ integration, you need to add reference to the assembly containing the entities you want to search from the cache. To do this, follow these steps:
In Additional References tab, click on the Browse button. This will open up a dialog box from where you can browse to the required assembly.
Select the assembly file and click on the Open button to add the assembly reference.
Step 3: Adding Required Assemblies and Namespaces
The last step into configuring NCache in LINQPad is to add the assemblies and namespaces required by NCache to successfully query cached data using LINQPad. Follow the steps provided below to understand how to provide these references:
- Go to Additional Namespace Imports tab from Query Properties dialog box.
- From the top-right corner, click on the Pick from Assemblies link which will display Assemblies and Namespaces sections.
- Choose Alachisoft.NCache.LinqPadIntegration.dll from Assemblies section and then choose Alachisoft.LinqPadIntegration from Namespaces section and click < Add Selected Namespaces.
- Similarly, perform the same steps for Alachisoft.NCache.Linq.dll by choosing it from the Assemblies section and Namespaces section.
- Also, choose SampleData.dll, which contains entities that you want to cache, by performing the same steps.
It is suggested to click Set as default for new queries button to persist references for all new queries.
- Click OK.