ArgoStore.Extensions.DependencyInjection 0.1.0

dotnet add package ArgoStore.Extensions.DependencyInjection --version 0.1.0                
NuGet\Install-Package ArgoStore.Extensions.DependencyInjection -Version 0.1.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ArgoStore.Extensions.DependencyInjection" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ArgoStore.Extensions.DependencyInjection --version 0.1.0                
#r "nuget: ArgoStore.Extensions.DependencyInjection, 0.1.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ArgoStore.Extensions.DependencyInjection as a Cake Addin
#addin nuget:?package=ArgoStore.Extensions.DependencyInjection&version=0.1.0

// Install ArgoStore.Extensions.DependencyInjection as a Cake Tool
#tool nuget:?package=ArgoStore.Extensions.DependencyInjection&version=0.1.0                

ArgoStore

Embedded transactional document store for .NET and .NET Core powered by Sqlite and JSON1 extension.

What is ArgoStore?

ArgoStore is a NETSTANDARD2.0 library that is using SQLite and JSON1 to store and retrieve JSON documents. It supports identity, indexes, nested objects, collections, LINQ queries, etc...

Is it stable?

Not fully. Even though it's work in progress and some features are missing (optimistic concurrency and async methods) library interfaces are mostly stable and not expected to change. Focus for future releases is on stabilizing select expressions, testing where predicates and improving performance.


Getting started


Console application (no dependency injection)

Create new project and add ArgoStore nuget reference.

dotnet add package ArgoStore

Define document type

public class Person
{
    public Guid Id { get; set; }
    public string Name { get; set; } = "";
    public int CookiesCount { get; set; }
    public string[] Roles { get; set; } = Array.Empty<string>();
}

Register document type

const string connectionString = "Data Source=c:\\temp\\mydb.sqlite";
ArgoDocumentStore store = new ArgoDocumentStore(connectionString);
store.RegisterDocument<Person>();

Insert data

using IArgoDocumentSession session = store.OpenSession();

session.Insert(new Person
{
    Name = "John Doe",
    CookiesCount = 1,
    Roles = new [] {"admin", "sales"}
});

session.SaveChanges();

Query data:

using IArgoQueryDocumentSession session = store.OpenQuerySession();

Person marco = session.Query<Person>()
    .First(x => x.Name.EndsWith("marco", StringComparison.OrdinalIgnoreCase));
Console.WriteLine($"{marco.Id}: {marco.Name}");


List<Person> sales = session.Query<Person>()
    .Where(x => x.Roles.Contains("sales"))
    .ToList();

Console.WriteLine("sales:");
foreach (Person salesPerson in sales)
{
    Console.WriteLine($"{salesPerson.Id}: {salesPerson.Name}");
}

ASP.NET Core application with default dependency injection

Create new web API application and add nuget dependency:

dotnet add package ArgoStore.Extensions.DependencyInjection

Add connection string to appsettings.json

{
  "ConnectionStrings": {
    "db": "Data Source=/path/to/db.sqlite"
  },
  "AllowedHosts": "*"
}

Edit Program.cs and register ArgoStore before var app = builder.Build(); line.

string dbConnectionString = builder.Configuration.GetConnectionString("db")
    ?? throw new InvalidOperationException("`ConnectionStrings:db` not set");

builder.Services.AddArgoStore(c =>
{
    c.ConnectionString(dbConnectionString);
    c.RegisterDocument<Person>();
});

This will register:

  • ArgoDocumentStore as singleton
  • IArgoDocumentStore as singleton
  • IArgoDocumentSession as scoped
  • IArgoQueryDocumentSession as transient

Use same session methods to query and modify documents as in console example.

For more examples see documentation.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 255 2/17/2023
0.0.1 216 2/17/2023