Skip to content

ObjectRedisMapping(ORM) is an object-redis mapper that enables .NET developers to work with a Redis database using .NET objects.

License

Notifications You must be signed in to change notification settings

Blueve/ORM-ObjectRedisMapping

Repository files navigation

ORM - Object Redis Mapping (Developing)

Build Status Codacy Badge

ObjectRedisMapping(ORM) is an object-redis mapper that enables .NET developers to work with a Redis database using .NET objects. It eliminating the need for most of the data-access code and Redis schema design that developers usually need to write.

This is a toy project developed out of personal interest. I will try to use this project to experiment with some problemes in my work. Although I have no way to apply the technology used in this project in my work, I believe that the experience I gained in developing this project will be of great benefit to me.

If you are interested in this project too, you are welcome to put forward your suggestions in Issues and you are also welcome to contribute this project with me.


SINCE THIS PROJECT IS UNDER DEVELOPING, THE SHOW CASE BELOW IS JUST FOR PREVIEW THE API AND THE USAGE.

Show Case

Store to Redis

var person1 = new Person
{
    Name = "Tom",
    Age = 18,
    Fellows = new List<Person>()
};
var person2 = new Person
{
    Name = "Jerry",
    Age = 10
    Fellows = new List<Person>()
};
person1.Fellows.Add(person2);
person2.Fellows.Add(person1);

dbContext.Save<Person>(person1);

// Redis
// PersonTom -> True
// PersonTomName -> Tom
// PersonTomeAge -> 18
// PersonTomFellows -> 1
// PersonTomFellows0 -> Jerry
// PersonJerry -> True
// PersonJerryName -> Jerry
// PersonJerryAge -> 10
// PersonJerryFellows -> 1
// PersonJerryFellows0 -> Tom

Fetch from Redis

var person = dbContext.Find<Person>("Tom");
Console.WriteLine(person.Partern.Name); // Jerry
Console.WriteLine(person.Partern.Age); // 10
Console.WriteLine(person.Fellows[0].Name); // Tom
Console.WriteLine(person.Fellows[0].Fellows[0].Age); // 18

Update in place by a dynmic proxy

var person = dbContext.Find<Person>("Tom");
person.Age = 19;
person.Fellows[0].Age = 11;

// Redis
// PersonTomAge -> 11
// PersonJerryAge -> 18

Store a linked-list

var head = new ListNode
{
    Val = 1,
    Next = new ListNode
    {
        Val = 2,
        Next = new ListNode
        {
            Val = 3
        }
    }
};
dbContext.Save<ListNode>(head);

// Redis
// ListNode1 -> True
// ListNode1Val -> 1
// ListNode1Next -> 2
// ListNode2 -> True
// ListNode2Val -> 2
// ListNode2Next -> 3
// ListNode3 -> True
// ListNode3Val -> 3

Contribution Guide

// TODO


Licence

MIT License

Copyright (c) 2019 Blueve

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

ObjectRedisMapping(ORM) is an object-redis mapper that enables .NET developers to work with a Redis database using .NET objects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages