Aerospike is a distributed, scalable NoSQL database.
And Dapper.Aerospike is a fluent mapper that brings type safety and reducing some of the brittleness of the code.
Available for .NET Standard 2.0+
PM> Install-Package Dapper.Aerospike
// define set with Client
ISet set = new Set<Order>(Client, Namespace, optional setName);
set.KeyProperty(p => p.Id);
set.Property(p => p.Number);
set.SetValueBuilder((record, properties) =>
{
return new Order()
{
Id = record.GetLong(properties[nameof(Order.Id)].BinName),
Number = record.GetString(properties[nameof(Order.Number)].BinName)
};
});
// Add to database
set.Add(order);
// Get from database
Order order = set.Get(orderId);
Define client
// define DB set
ISet set = new DbSet<Order>(Host,Port,Namespace, optional setName);
set.KeyProperty(p => p.Id);
set.Property(p => p.Number);
// define set
ISet set = new Set<Order>(Namespace, optional setName);
set.KeyProperty(p => p.Id);
set.Property(p => p.Number);
// define set with Client
ISet set = new Set<Order>(Client, Namespace, optional setName);
set.KeyProperty(p => p.Id);
set.Property(p => p.Number);
Get and query from database
// define set
set.SetValueBuilder((record, properties) =>
{
return new Order()
{
Id = record.GetLong(properties[nameof(Order.Id)].BinName),
Number = record.GetString(properties[nameof(Order.Number)].BinName)
};
});
// Get from database
Order order = set.Get(orderId, cancellationToken);
// Query all from database
List<Order> orders = set.Query();
Get bins name
string bins = set.GetBinNames();
Get bins
Bin[] bins = set.GetBins(order);
Set custom bin builder
prop.SetBinBuilder((o, p) => new Bin(p.BinName, o.Id));
Set custom value builder
prop.SetValueBuilder((r, p) => r.GetLong(p.BinName));
Set key property
set.KeyProperty(p => p.Id);
// get key
Key key = set.Key(orderId);