Coder Social home page Coder Social logo

stored's Introduction

Stored Circle CI Build status

A light weight data store for storing entities with support for unit of work.

There are currently 2 supported providers in-memory (really fast) and Postgres.

Getting an entity

var store = new PostgresStore(connectionString);

using (var session = store.CreateSession())
{
    var id = new Guid("3E137227-2BEF-451F-B392-482CDC2216B0");

    var car = session.Get<Car>(id);
}

Saving an entity

var store = new PostgresStore(connectionString);

using (var session = store.CreateSession())
{
    session.Create(new Car { Make = "Aston Martin", Model = "DB9 Volante" });
    session.Commit();
}

Modifying an entity

var store = new PostgresStore(connectionString);

using (var session = store.CreateSession())
{
    var car = session.Get<Car>(carId);
	car.Model = "Mustang";

    session.Modify(car);
    session.Commit();
}

Deleting an entity

var store = new PostgresStore(connectionString);

using (var session = store.CreateSession())
{
    var car = session.Get<Car>(carId);

    session.Delete(car);
    session.Commit();
}

Querying for entities

I haven't had time to build a Linq provider yet - feel free to send a pull request for one.

var store = new PostgresStore(connectionString);

using (var session = store.CreateSession())
{
	session.Create(new Car { Make = "Toyota", Model = "Rav4" });
    session.Create(new Car { Make = "Aston Martin", Model = "DB9 Volante" });
    session.Create(new Car { Make = "Toyota", Model = "Corolla" });
    session.Commit();

    var items = session.Query<Car>()
                .Where(x => x.Make).Equal("Toyota")
                .ToList();
}

Ordering entities

var store = new PostgresStore(connectionString);

using (var session = store.CreateSession())
{
	session.Create(new Car { Make = "Toyota", Model = "Rav4" });
    session.Create(new Car { Make = "Aston Martin", Model = "DB9 Volante" });
    session.Create(new Car { Make = "Toyota", Model = "Corolla" });
    session.Commit();

    var item = session.Query<Car>()
                      .OrderBy(x => x.Make)
                      .ToList();
}

Bulk create

var store = new PostgresStore(connectionString);

using (var session = store.CreateSession())
{
    var items = new List<Car>
    {
        new Car { Make = "Aston Martin", Model = "DB9 Volante" },
        new Car { Make = "Toyota", Model = "Rav4" }
    };

    // does not buffer in unit of work
    session.Advanced.BulkCreate(items);
}

Inspiration

Inspriation from this project has come from Raven DB and Biggy.

stored's People

Contributors

sandcastle avatar rsantosdev avatar

Stargazers

Ahmet MERAL avatar  avatar Marcos Dioni Lima avatar Chad Tolkien avatar  avatar

Watchers

 avatar James Cloos avatar  avatar

stored's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.