![]() |
VOOZH | about |
dotnet add package Aerospike.Database.LINQPadDriver --version 6.1.0
NuGet\Install-Package Aerospike.Database.LINQPadDriver -Version 6.1.0
<PackageReference Include="Aerospike.Database.LINQPadDriver" Version="6.1.0" />
<PackageVersion Include="Aerospike.Database.LINQPadDriver" Version="6.1.0" />Directory.Packages.props
<PackageReference Include="Aerospike.Database.LINQPadDriver" />Project file
paket add Aerospike.Database.LINQPadDriver --version 6.1.0
#r "nuget: Aerospike.Database.LINQPadDriver, 6.1.0"
#:package Aerospike.Database.LINQPadDriver@6.1.0
#addin nuget:?package=Aerospike.Database.LINQPadDriver&version=6.1.0Install as a Cake Addin
#tool nuget:?package=Aerospike.Database.LINQPadDriver&version=6.1.0Install as a Cake Tool
Aerospike for LINQPad 7/8 is a data context dynamic driver for interactively querying and updating an Aerospike database using "LINQPad". LINQPad is a Graphical Development Tool designed for rapid prototyping, interactive testing, data modeling, data mining, drag-and-drop execution, interactive debugging, etc. The Aerospike driver for LINQPad is designed to support all LINQPad capabilities including the enhanced ability to learn and use the Aerospike API directly.
Here is a subset of what you can perform using the driver:
The driver can, also, dynamically detect the structure of records within an Aerospike Set resulting in an easy-to-understand view much like a relational table with enhanced capabilities. Some of these capabilities are:
The LINQPad connection pane will display the different Aerospike components in an hierarchical manner where namespace is under Aerospike cluster connection. Aerospike Sets are under namespaces and bins are under Sets. Below screenshot shows the relationship between these components:
Each component can be dragged-and-dropped onto the LINQPad Query pane to be executed by LINQPad. The execution behavior will depend on the component. For example, a Set or Secondary Index will present the records within that component. For other components, the properties are displayed. In all cases, you can always execute the driver’s extension methods. These extension methods greatly simplify Aerospike API commands like Get, Put, Query, Operate, etc. plus, the ability to perform things like importing or exporting data. Of course, you can always use LINQ against Aerospike Sets or Secondary Indexes. Below is an example of some of the driver extensions:
Information about the cluster and namespaces can be obtained in the LINQPad connection pane. Below is an example showing cluster level information which includes the enabled features, configuration, nodes, version, total namespaces and sets, etc.
Below is an example of the namespace configuration information that is presented under the namespace icon.
Aerospike Sets and records are very easy to use. The detected bins in a record are integrated into LINQPad and are treated as C# properties. As such, features like IntelliSense and Autocompletion just work. You can also access bins within a record by using the bin name.
Since Aerospike is a schemaless database, a record can consist of varying number of bins, or a bin can have different data types between records. The driver can handle these conditions seamlessly.
Implicit data conversion (auto-values) eliminates the need to test and casts a bin’s value so that it can be used directly in any operation. Below is an example that shows how implicit conversion works. The set, “graphDeviceNodeIdSet”, has a bin named “nodeID” that consists of two different data type values. Some records have a list value while others have a string value. This example uses the “where” clause which compares each record in the set looking for a numeric value of 367 or the value “a” in the list values.
The driver supports the execution of UDFs by calling the Execute extension method. The Execute method will reflect the actual arguments used in the UDF. Below is an example:
At any time, you can use the underlying Aerospike API directly or a combination of API or driver extension methods. Below is an example:
void Main()
{
//Using Aerospike API
var cPolicy = new ClientPolicy();
using var client = new AerospikeClient(cPolicy, "localhost", 3000);
//Insert 3 records, with MapPolicy KEY_ORDERED
var key1 = new Key("test", "s1", 1);
var key2 = new Key("test", "s1", 2);
var key3 = new Key("test", "s1", 3);
var policy = new WritePolicy();
policy.recordExistsAction = RecordExistsAction.UPDATE;
client.Put(policy, key1, new Bin("id", "groupID1"));
client.Put(policy, key2, new Bin("id", "groupID2"));
client.Put(policy, key3, new Bin("id", "groupID3"));
for (int i = 0; i < 25; i++)
{
client.Operate(null, key1,
ListOperation.Insert("myList", 0, Value.get(value)),
ListOperation.Trim("myList", 0, 20) );
}
}
The driver supports serialize and deserialize any C# object to/from an Aerospike record. Native C# types are stored as Aerospike data type. Unsupported types like DateTime, DateTimeOffset, Timespan, etc. are serialized as an ISO string or a numeric value based on behavior defined in the connection dialog. This behavior can also be changed programmability by the driver’s API or by providing a custom serializer.
C# collections will be serialized into an Aerospike CDT. C# public properties or fields will be serialized into an Aerospike bin where the bin name is the same name as the property/field. Fields can be ignored, and bin names can be different based on the use of C# attributes (Aerospike.Client.BinIgnore, Aerospike.Client.BinName). Any nested class will be serialized as an Aerospike JSON document.
The driver can deserialize an Aerospike record into a C# class. Just like serialization, bins are mapped to properties and fields using attributes as defined above. The driver will determine the best possible constructor to instantiate the class. This behavior can be changed by using the “Aerospike.Client.Constructor” attribute. Below is an example:
//This is from the POCO Aerospike LINQPad Example script
void Main()
{
//If true, the read record is re-written with a different PK to demo how PICO are written back to the DB.
var reWriteAsDiffPK = true;
var customerInvoices = Demo.CustInvsDoc
.AsEnumerable()
.Select(cid => cid.Cast<Customer>(cid.PK)).ToArray();
customerInvoicescustomerInvoices.OrderBy(i => i.LastName)
.ThenBy(i => i.LastName)
.ThenBy(i => i.Id)
.Dump("Customer Invoices class instances created from the DB", 0);
if(reWriteAsDiffPK)
{
var newRecs = new List<long>();
foreach (var element in customerInvoices)
{
var newPK = element.Id * 1000; //Change the PK
//Create DB Records from the Customer instances
Demo.CustInvsDoc.WriteObject(newPK, element);
newRecs.Add(newPK); //Removed new record later...
}
/Note that bin "Fax" is present in the DB (and list as a known bin in the Set's Bin list pane) but not as a property in the Customer Class
// Also bin "Company" is present in the DB and wasn't detected by the Set's Bin list pane and isn't a property either.
// As such, records that have defined "Company" bin, will have an ExpandoObject value indicating that records has additional bins.
Demo.CustInvsDoc.AsEnumerable()
.OrderBy(cid => cid.LastName)
.ThenBy(cid => cid.FirstName)
.ThenBy(cid => cid.PK)
.Dump("Customer Invoices Docs set From DB (rewritten with new PKs)", 1);
LINQPad.Util.ReadLine("Press <Enter> to continue and remove newly written records!".Dump());
foreach (var removePK in newRecs)
{
Demo.CustInvsDoc.Delete(removePK);
}
}
}
//Class definations for Customer and Invoice
public class Customer
{
/// <summary>
/// The constructor used to create the object.
/// Note that the property "Invoices" will be set using the accessor.
/// </summary>
[Aerospike.Client.Constructor]
public Customer(long id,
string address,
string city,
string country,
string email,
string firstName,
string lastName,
string phone,
string postalCode,
string state,
int supportRepId)
{
this.Id = id;
this.Address = address;
this.City = city;
this.Country = country;
this.Email = email;
this.FirstName = firstName;
this.LastName = lastName;
this.Phone = phone;
this.PostalCode = postalCode;
this.State = state;
this.SupportRepId = supportRepId;
}
/// <summary>
/// This property will contain the primary key value but will not be written in the set as a bin.
/// </summary>
[Aerospike.Client.PrimaryKey]
[Aerospike.Client.BinIgnore]
public long Id { get; }
public string Address{ get; }
public string City { get; }
public string Country { get; }
public string Email { get; }
public string FirstName { get; }
public string LastName { get; }
public string Phone { get; }
public string PostalCode { get; }
public string State { get; }
public int SupportRepId { get; }
public List<Invoice> Invoices { get; set; }
}
public class Invoice
{
[Aerospike.Client.Constructor]
public Invoice(string billingAddress,
string billingCity,
string billingCountry,
string billingCode,
string billingState,
DateTime invoiceDate,
decimal total,
List<InvoiceLine> lines)
{
this.BillingAddress = billingAddress;
this.BillingCity = billingCity;
this.BillingCode = billingCode;
this.BillingState = billingState;
this.BillingCountry = billingCountry;
this.InvoiceDate = invoiceDate;
this.Total = total;
this.Lines = lines;
}
/// <summary>
/// Uses the bin name BillingAddr instead of the property name.
/// </summary>
[Aerospike.Client.BinName("BillingAddr")]
public string BillingAddress { get;}
public string BillingCity { get; }
[Aerospike.Client.BinName("BillingCtry")]
public string BillingCountry { get; }
public string BillingCode { get; }
public string BillingState { get; }
/// <summary>
/// Notice that the driver will convert the DB value into the targed value automatically.
/// The value is stored as a sting in the DB but converted to a date/time. Upon write it will be converted from back to a native DB type (e.g., string or long depending on configuration).
/// </summary>
public DateTime InvoiceDate { get; }
/// <summary>
/// This is stored as a double in the DB but is automatically converted to a decimal.
/// </summary>
public Decimal Total { get; }
public IList<InvoiceLine> Lines { get; }
}
public class InvoiceLine
{
[Aerospike.Client.Constructor]
public InvoiceLine(long invoiceId,
long quantity,
long trackId,
decimal unitPrice)
{
this.InvoiceId = invoiceId;
this.Quantity = quantity;
this.TrackId = trackId;
this.UnitPrice = unitPrice;
}
public long InvoiceId { get; }
public long Quantity { get; }
public long TrackId { get; }
public decimal UnitPrice { get; }
}
Below is the output from LINQPad:
You can read and write Json to or from an Aerospike namespace, set, or record by means of the “ToJson” and “FromJson“ methods. The driver supports embedded JSON data types which are compatible with Json generated from multiple databases. The driver uses Json.Net when working with Json.
The driver supports the use of the Aerospike Document API. This feature can be turned on or off from within the connection dialog. Below is an example where we obtain all artist recording track 2527 purchased by a customer.
//ORM -- Find all tracks for TrackId 2527 and return those customers who bought this track
var fndTrackIdsInstances = from custInvoices in Demo.CustInvsDoc.AsEnumerable()
let custInstance = custInvoices.Cast<Customer>()
where custInstance.Invoices
.Any(d => d.Lines.Any(l => l.TrackId == 2527))
select custInstance;
fndTrackIdsInstances.Dump("Found Using ORM/POCO", 0);
//.Net CDTs -- Find all tracks for TrackId 2527 and return those customers who bought this track
// BTW you can configure how documents from Aerospike are presented.
// The default is to treat documents as JObject but you can configure this (via the connection properties)
// to present them as .Net CDTs (i.e., List and Dictionary).
var fndTrackIdsCDT = from custInvoices in Demo.CustInvsDoc.AsEnumerable()
let custInvoiceLines = custInvoices.Invoices.ToCDT() //Not required if document mode was disabled
where custInvoiceLines
.SelectMany(il => ((IList<object>)il["Lines"]).Cast<IDictionary<string, object>>())
.Any(l => (long)l["TrackId"] == 2527)
select custInvoices;
fndTrackIdsCDT.Dump("Found Using Linq CDT", 0);
//JObject -- Find all tracks for TrackId 2527 and return those customers
var fndTrackIdsJObj = from custInvoices in Demo.CustInvsDoc.AsEnumerable()
let custInvoiceLines = custInvoices.ToJson()["Invoices"]
.Children()["Lines"].Children()
where custInvoiceLines.Any(l => l["TrackId"].Value<int>() == 2527)
select custInvoices;
fndTrackIdsJObj.Dump("Found Using Linq JObject", 0);
//Json Pathing -- Find all tracks for TrackId 2527 and return those customers
var fndTrackIdsJPath = from custInvoices in Demo.CustInvsDoc.AsEnumerable()
where custInvoices.Invoices.ToJArray().SelectToken("$..Lines[?(@.TrackId == 2527)]") != null
select custInvoices;
fndTrackIdsJPath.Dump("Found Using Json Path", 0);
Below is the output from LINQPad:
The driver can import a valid JSON file into an Aerospike namespace or set from many different external databases via the “ImportJsonFile” method. Each JSON property will be mapped to an Aerospike bin, JSON collection types will be transformed into the corresponding Aerospike CDT, nested JSON objects will be treated as Aerospike JSON documents, etc. This behavior can be controlled via the method’s arguments and connection dialog properties. Aerospike supports the following common in-line JSON types:
Below is an example of importing the Shipwreck sample dataset into the “Demo” namespace and creating the Aerospike set “shipwrecks”.
Demo.ImportJsonFile(@"C:\MonogoDBSampleCollection\shipwrecks.json", "shipwrecks")
The driver can also export and import between Aerospike cluster and/or namespaces and sets using the Export and Import methods. Below is an example of an export from the “players” Aerospike set.
test.players.Export(@"c:\users\randersen_aerospike\Desktop\player.json");
Below is an example of importing a JSON file:
test.players.Import(@"c:\users\randersen_aerospike\Desktop\player.json");
test.Import(@"c:\users\randersen_aerospike\Desktop\player.json", "players");
Support for TLS encryption and authentication is fully supported by enabling these options in the connection dialog. This includes using the LIINQPad Password Manager integration. If the password manager is not used, all passwords are encrypted using the Windows Data Protection API.
The connection dialog is used to establish a connection to an Aerospike cluster.
This dialog also defines the connection policies and Aerospike LINQPad features. Each field/property will typically have a “tooltip” providing additional information. Blue underlined text is a hyperlink that will take you to additional information about the topic.
The dialog is divided into multiple sections.
The sections are:
The properties are:
The options needed to establish a TLS connection to an Aerospike cluster.
Fields are:
The TLS protocols that can be used. Multiple protocols can be selected.
The common name (i.e., Issue To) that was used in the certificate. For more information click here.
Note: If you leave this blank and press the “Test” button, the certificate is validated, and this field is filled on the value found in the certificate.
The client certificate file as a path. You can select the file by pressing the “Select a File” button on the far right.
Note: If you press the “Test” button, the certificate is validated ensuing that the chaining and TLS Common Name are correct. It ensures that the certificate is not expired.
Select the client certificate file.
Reject server certificates whose serial numbers match.
If enabled, TLS is only used for authentication (login).
This panel provides information on how to handle things like serialization, Set-Bin Datatype discovery, conversion, etc.
The fields are:
Below is an example of Record Display View:
Below is an example of Dynamic Display View:
Auto-Values are a wrapper around Aerospike DB values so that working with unstructured data is simple and risk free of exceptions like null reference and invalid cast.
They provide a rich set of functions to work with conversions from or to DB and .Net values. They have the following main features:
For more information, see the Auto-Values blog.
You can still perform queries and API calls using the driver’s extension APIs against the “null” set. Below is an example of an API call to obtain the records for Aerospike set “Artist”:
test.NullSet.Where(ns => ns.Aerospike.SetName == "Artist")
Below is the output:
The driver can generate Get, Put, and Batch statements from a result set. The code generated can be the Aerospike native API or the LINQPad extended API. Below are some examples of generating native API for batch statements:
testsc.Track.Take(3).ToAPICodeBatch(useAerospikeAPI: true)
ASClient.Get(null, new List<BatchRead>(){
new BatchRead(null, new Key("testsc", "Track", 2984L), true),
new BatchRead(null, new Key("testsc", "Track", 782L), true),
new BatchRead(null, new Key("testsc", "Track", 3192L), true)})
ASClient.Operate(null,
new List<BatchRecord>(){
new BatchWrite(null,
new Key("testsc", "Track", 2984L),
new Operation[] {
Operation.Put(new Bin("AlbumId", Value.Get(236L))),
Operation.Put(new Bin("Bytes", Value.Get(10227333L))),
Operation.Put(new Bin("Composer", Value.Get("Bono, The Edge, Adam Clayton, and Larry Mullen"))),
Operation.Put(new Bin("GenreId", Value.Get(1L))),
Operation.Put(new Bin("MediaTypeId", Value.Get(1L))),
Operation.Put(new Bin("Milliseconds", Value.Get(315167L))),
Operation.Put(new Bin("Name", Value.Get("If You Wear That Velvet Dress"))),
Operation.Put(new Bin("UnitPrice", Value.Get(0.99D)))}),
new BatchWrite(null,
new Key("testsc", "Track", 3192L),
new Operation[] {
Operation.Put(new Bin("AlbumId", Value.Get(250L))),
Operation.Put(new Bin("Bytes", Value.Get(255245729L))),
Operation.Put(new Bin("GenreId", Value.Get(19L))),
Operation.Put(new Bin("MediaTypeId", Value.Get(3L))),
Operation.Put(new Bin("Milliseconds", Value.Get(1278333L))),
Operation.Put(new Bin("Name", Value.Get("Boys and Girls"))),
Operation.Put(new Bin("UnitPrice", Value.Get(1.99D)))}),
new BatchWrite(null,
new Key("testsc", "Track", 782L),
new Operation[] {
Operation.Put(new Bin("AlbumId", Value.Get(62L))),
Operation.Put(new Bin("Bytes", Value.Get(7832790L))),
Operation.Put(new Bin("Composer", Value.Get("Ian Gillan/Ian Paice/Jon Lord/Ritchie Blckmore/Roger Glover"))),
Operation.Put(new Bin("GenreId", Value.Get(1L))),
Operation.Put(new Bin("MediaTypeId", Value.Get(1L))),
Operation.Put(new Bin("Milliseconds", Value.Get(239830L))),
Operation.Put(new Bin("Name", Value.Get("Never Before"))),
Operation.Put(new Bin("UnitPrice", Value.Get(0.99D)))})})
The LINQPad driver supports Aerospike MRTs using the Aerospike native API and the extension API.
The extension API manages the associated policies for easy use. Below are the extension API functions:
Calling “CreateTransaction” which will return an ATransaction object which acts like a namespace object. All the extension APIs (e.g., Get, Put, CopyRecods, Import, etc.) can be used with MRT with no effort.
Like always if you wish to use the Aerospike native API you can at any time. The default policies for the Extension MRT “set” or “namespace” will be properly enabled to support native MRTs.
For more information about Aerospike MRTs see this page. For more information about the MRT extensions, see the MRT.linq file in the LINQPad sample section/folder.
Sample scripts can be found in the LINQPad Sample tree view tab under “nuget” or in the “linqpad-samples” folder in GitHub.
The sample scripts are:
LINQPad API documentation can be found in the Help Folder.
Add Connection Link.View more drivers…Show all drivers” and type Aerospike.Obtain the latest driver from the Driver folder and download to your computer.
Add Connection Link.View more drivers…Install driver from .LPX6 file… and select downloaded lpx6 file.There are multiple ways to install Aerospike DB.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 net6.0 is compatible. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 is compatible. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 6.1.0 | 145 | 1/30/2026 | |
| 6.0.7 | 375 | 8/5/2025 | |
| 6.0.5 | 221 | 7/11/2025 | |
| 6.0.4 | 311 | 7/9/2025 | 6.0.4 is deprecated because it is no longer maintained. |
| 6.0.3 | 308 | 7/8/2025 | 6.0.3 is deprecated. |
| 6.0.2 | 304 | 7/8/2025 | 6.0.2 is deprecated because it is no longer maintained and has critical bugs. |
| 6.0.0 | 270 | 5/17/2025 | |
| 5.6.0 | 253 | 5/17/2025 | |
| 5.0.0 | 330 | 2/14/2025 | 5.0.0 is deprecated because it is no longer maintained. |