Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/achehre/dapper.aerospike
Dapper.Aerospike is a fluent mapper that brings type safety and reducing some of the brittleness of the code.
https://github.com/achehre/dapper.aerospike
aerospike csharp dapper database dotnet nosql
Last synced: 3 days ago
JSON representation
Dapper.Aerospike is a fluent mapper that brings type safety and reducing some of the brittleness of the code.
- Host: GitHub
- URL: https://github.com/achehre/dapper.aerospike
- Owner: AChehre
- Created: 2021-05-17T16:34:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-07-15T21:18:09.000Z (over 3 years ago)
- Last Synced: 2024-12-13T03:40:02.219Z (22 days ago)
- Topics: aerospike, csharp, dapper, database, dotnet, nosql
- Language: C#
- Homepage:
- Size: 86.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[projectUri]: https://github.com/AChehre/Dapper.Aerospike
[projectGit]: [email protected]:AChehre/Dapper.Aerospike.git# Dapper.Aerospike
[![NuGet](https://img.shields.io/nuget/v/Dapper.Aerospike.svg)](https://www.nuget.org/packages/Dapper.Aerospike)[Aerospike](https://github.com/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+](https://docs.microsoft.com/en-gb/dotnet/standard/net-standard)### NuGet
```
PM> Install-Package Dapper.Aerospike
```### Example
```C#
// define set with Client
ISet set = new Set(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
```C#
// define DB set
ISet set = new DbSet(Host,Port,Namespace, optional setName);
set.KeyProperty(p => p.Id);
set.Property(p => p.Number);// define set
ISet set = new Set(Namespace, optional setName);
set.KeyProperty(p => p.Id);
set.Property(p => p.Number);// define set with Client
ISet set = new Set(Client, Namespace, optional setName);
set.KeyProperty(p => p.Id);
set.Property(p => p.Number);
```Get and query from database
```C#
// 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 orders = set.Query();
```Get bins name
```C#
string bins = set.GetBinNames();
```
Get bins
```C#
Bin[] bins = set.GetBins(order);
```
Set custom bin builder
```C#
prop.SetBinBuilder((o, p) => new Bin(p.BinName, o.Id));
```
Set custom value builder
```C#
prop.SetValueBuilder((r, p) => r.GetLong(p.BinName));
```
Set key property
```C#
set.KeyProperty(p => p.Id);// get key
Key key = set.Key(orderId);
```