Skip to content

Latest commit

 

History

History

RepoDb.MySql

MySqlBuild MySqlHome MySqlVersion MySqlReleases MySqlUnitTests MySqlIntegrationTests

RepoDb.MySql - a hybrid .NET ORM library for MySQL (using MySql.Data).

RepoDB is an open-source .NET ORM library that bridges the gaps of micro-ORMs and full-ORMs. It helps you simplify the switch-over of when to use the BASIC and ADVANCE operations during the development.

Important Pages

  • GitHub Home Page - to learn more about the core library.
  • Website - docs, features, classes, references, releases and blogs.

Community Engagements

Dependencies

  • MySql.Data - the data provider used for MySql.
  • RepoDb - the core library of RepoDB.

License

Apache-2.0 - Copyright © 2019 - Michael Camara Pendon


Installation

At the Package Manager Console, write the command below.

> Install-Package RepoDb.MySql

Or, visit our installation page for more information.

Get Started

First, the bootstrapper must be initialized.

RepoDb.MySqlBootstrap.Initialize();

Note: The call must be done once.

After the bootstrap initialization, any library operation can then be called.

Or, visit the official get-started page for MySQL.

Query

using (var connection = new MySqlConnection(ConnectionString))
{
	var customer = connection.Query<Customer>(c => c.Id == 10045);
}

Insert

var customer = new Customer
{
	FirstName = "John",
	LastName = "Doe",
	IsActive = true
};
using (var connection = new MySqlConnection(ConnectionString))
{
	var id = connection.Insert<Customer>(customer);
}

Update

using (var connection = new MySqlConnection(ConnectionString))
{
	var customer = connection.Query<Customer>(10045);
	customer.FirstName = "John";
	customer.LastUpdatedUtc = DateTime.UtcNow;
	var affectedRows = connection.Update<Customer>(customer);
}

Delete

using (var connection = new MySqlConnection(ConnectionString))
{
	var customer = connection.Query<Customer>(10045);
	var deletedCount = connection.Delete<Customer>(customer);
}