LunaTTvBot / LunaBot

0 stars 1 forks source link

Add EF6 / SQLite package, Datastore, ConString #33

Closed CapCalamity closed 8 years ago

CapCalamity commented 8 years ago

PR to close #31


Things to know:

How to save and load arbitrary objects to DB:

var someContext = new GenericDatabaseContext<SomeClass>();
someContext.Table.Add(new SomeClass());
someContext.SaveChanges();

foreach (var someClass in someContext.Table)
{
    _logger.Warn($"{someClass.Id} - {someClass.CreatedOn}");
}

How to attach a value to an object:

var user = new User("Some_Guy_69");
user.Set("FirstRecorded", DateTime.Now);
// alternatively, use
// Extension.Set(user, "FirstRecorded", DateTime.Now);
CapCalamity commented 8 years ago

any toughts about the current implementation of the Db classes? @SuNflOw1991

iPaat commented 8 years ago

Seems to be okay for me :+1:

CapCalamity commented 8 years ago

With the GenericDatabaseContext, you can now save your objects to a DB. There are some things one needs to know though:


With the Extension class you can save a key/value pair to the Database.
Can be used with Extensions.Set / Extension.Get, or use the Extension methods .Set / .Get

iPaat commented 8 years ago

Good work here! :+1: I like it very much! Thanks a lot :)