GithubHelp home page GithubHelp logo

marcodafonseca / dynamo.orm Goto Github PK

View Code? Open in Web Editor NEW
13.0 5.0 0.0 125 KB

An async ORM built for Amazon Web Service's DynamoDb in .Net Standard

License: MIT License

C# 100.00%
aws dynamodb net-standard net-standard-2

dynamo.orm's Introduction

Dynamo.ORM

An async ORM built for Amazon Web Service's DynamoDb in .Net Standard This is still in beta

Please don't hesitate to log issues or requests on GitHub. We are working everyday to make this more and more robust to ensure it will help more developers.

The examples below use the local Amazon DynamoDb you would setup on your machine

Example Usage

Example setup of a table model called 'People'

[DynamoDBTable("People")]
public class PersonModel : Base
{
    [DynamoDBHashKey]
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public DateTime CreatedDate { get; set; }
}

Example configuration

var config = new AmazonDynamoDBConfig
{
    ServiceURL = "http://localhost:8000/"
};
var client = new AmazonDynamoDBClient(config);
var repository = new Repository(client);

Example adding a Person with the HashKey '1'

var model = new PersonModel();

model.Id = 1;
model.FirstName = "John";
model.LastName = "Smith";
model.CreatedDate = DateTime.Now;

await repository.Add(model);

Example getting a Person entry with the HashKey '1'

var entity = await repository.Get<PersonModel>(1);

Example updating a Person entry with the HashKey '1'

var model = new PersonModel();

model.Id = 1;
model.FirstName = "John";
model.LastName = "Smith";
model.CreatedDate = DateTime.Now;

await repository.Update(model);

Example deleting a Person entry with the HashKey '1'

await repository.Delete<PersonModel>(1);

If you don't want to use the Table Name attribute you can provide the Table Name as a parameter on repository Call. Examples of calls made with additional parameter

var model = new PersonModel();

model.Id = 1;
model.FirstName = "John";
model.LastName = "Smith";
model.CreatedDate = DateTime.Now;

await repository.Add(model, "tableName");
await repository.Get<PersonModel>(model.Id, "tableName");
await repository.Get<PersonModel>(x => x.FirstName == "Fake", "tableName");
await repository.List<PersonModel>(x => x.Id < 20 && x.Id >= 10, "tableName")
await repository.Update(model, "tableName");
await repository.Delete(model, "tableName");

Release Notes

Click here to view all the release notes

Version 0.4.0

  • ! Breaking Changes ! - Changed return type of List function from List to IList
  • Added pagination parameters to existing List method
  • Added custom exception for paging, PageNotFoundException
  • Added method for retrieving approximate item count for a table.

Important Links

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.