Skip to content

Dapper.Aerospike is a fluent mapper that brings type safety and reducing some of the brittleness of the code.

Notifications You must be signed in to change notification settings

AChehre/Dapper.Aerospike

Repository files navigation

Dapper.Aerospike

NuGet

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.

Installation

Available for .NET Standard 2.0+

NuGet

PM> Install-Package Dapper.Aerospike

Example

// 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);

How to use

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);

About

Dapper.Aerospike is a fluent mapper that brings type safety and reducing some of the brittleness of the code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages