TheOne.OrmLite.MySqlConnector

OrmLite for MySql with MySqlConnector


Keywords
Orm, OrmLite, MySql, MySqlConnector, netcore, netstandard20, npgsql, oracle, sqlite, sqlserver
License
MIT
Install
Install-Package TheOne.OrmLite.MySqlConnector -Version 0.1.1

Documentation

TheOne.OrmLite - Fast, Simple, Typed ORM for .NET


Usage

First install the NuGet package of the RDBMS you want to use, e.g:

PM> Install-Package TheOne.OrmLite.SqlServer

All NuGet packages and available Dialect Providers:

To configure OrmLite you need the DB Connection string along the Dialect Provider of the RDBMS you're connecting to, e.g:

var dbFactory = new OrmLiteConnectionFactory(connectionString, SqlServerDialect.Provider);

If you're using an IOC you can register OrmLiteConnectionFactory as a singleton, e.g:

container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(":memory:", SqliteDialect.Provider));

You can then use the dbFactory to open ADO.NET DB Connections to your database.

using (var db = dbFactory.Open()) {
    db.CreateTable<Poco>();

    db.Insert(new Poco { Id = 1, Name = "Seed Data"});

    var result = db.SingleById<Poco>(1);
    result.ToJson(); // = { "Id": 1, "Name": "Seed Data" }
}

Examples

Change connection strings in Config.cs as necessary.

Logging

See LibLog