emoji_people

Easy to Use

RepoDB operations were implemented as extended methods of IDbConnection object. For as long the connection is open, any operations can then be called against the database.

flash_on

High Performant

RepoDB caches the already-generated compiled expressions for future reusabilities and executions. It understands your schema to create the most optimal compiled expression AOT.

memory

Memory Efficient

RepoDB extracts and caches the object properties, execution contexts, object mappings and SQL statements. It is reusing them all throughout the process of transformations and executions.

dynamic_feed

Dynamic and Hybrid

RepoDB is a micro-ORM that provides some advance features of the full-fledged ORMs. It significantly help the developers to simplify the experience when context-switching during the development.

public

Open-Source Software

RepoDB is an open-source software and will always be free. It is authored to further improve the .NET data access experiences and solutions, together with the collective ideas of the community.

high_quality

High Quality

RepoDB is a high-quality micro-ORM supported by thousands real-life based Unit and Integration Tests. It is highly tested by various critical systems that are running in production environment.

Official Benchmark Results

What you will learn

Connection

Simply instantiate a connection object (with proper connection string) and you can then use it right away. Let’s get started

using (var connection = new SqlConnection(connectionString))
{
    var id = connection.Insert<Customer, int>(new Customer
    {
        Name = "John",
        Doe = "Doe")
    });
}
Transaction

Make the execution more ACID by placing the execution context into a transaction object. Learn more

using (var connection = new SqlConnection(connectionString).EnsureOpen())
{
    using (var transaction = connection.BeginTransaction())
    {
        connection.Insert<Customer>(customer, transaction);
        transaction.Commit();
    }
}
Hints

Optimize your query execution by maximizing and leveraging the power of table optimizers. Learn more

using (var connection = new SqlConnection(connectionString))
{
    connection.Query<Customer>(c => c.Id == 10045,
        hints: SqlServerTableHints.NoLock);
}
Cache

Avoid the frequent roundtrips in your database by placing the shared datasets into a cache object. Learn more

var cache = CacheFactory.GetMemoryCache();
using (var connection = new SqlConnection(connectionString))
{
    connection.QueryAll<Product>(cacheKey: "AllProducts", cache: cache);
}
Class Mapping

Organize the name of your entity models by placing the correct mappings equivalent to your database objects. Learn more

[Map("[sales].[Customer]")]
public class Customer
{
    [Primary, Identity, Map("CustomerId")]
    public int Id { get; set; }

    [Map("FName")]
    public string FirstName { get; set; }

    [Map("LName")]
    public string LastName { get; set; }
}
Implicit Mapping

Make your entity models free from any attribute by leveraging the implicit mapping functionality. Learn more

public class Customer
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

FluentMapper
    .Entity<Customer>()
    .Table("[sales].[Customer]")
    .Primary(e => e.Id)
    .Identity(e => e.Id)
    .Column(e => e.FirstName, "FName")
    .Column(e => e.LastName, "LName");
Dynamics

Work without even a data model in place with the use of dynamics. Learn more

using (var connection = new SqlConnection(connectionString))
{
    var entity = new
    {
        Id = 10045,
        Name = "James",
        LastUpdatedUtc = DateTime.UtcNow
    }
    var rows = connection.Update("[sales].[Customer]", entity);
}
Targeted

Make a targeted operations within your entity models and/or dynamic objects. Learn more

using (var connection = new SqlConnection(connectionString))
{
    var entity = new Customer
    {
        Id = 10045,
        Name = "James",
        LastUpdatedUtc = DateTime.UtcNow
    }
    var fields = Field.Parse<Customer>(e => new { e.Id, e.Name });
    var rows = connection.Merge<Customer>(entity, fields: fields);
}
Class Handler

Handle the serialization/deserialization process of the model from/to your database with class handlers. Learn more

[ClassHandler(typeof(CustomerClassHandler))]
public class Customer
{
    public int Id { get; set; }

    public Address Address { get; set; }
}
Property Handler

Customize the column transformations in/out from your database with property handlers. Learn more

public class Customer
{
    public int Id { get; set; }

    [PropertyHandler(typeof(CustomerAddressPropertyHandler))]
    public Address Address { get; set; }
}
Batch Operations

Significantly improve the CRUD operations by utilizing the batch operations. Learn more

using (var connection = new SqlConnection(connectionString))
{
    var customers = GetCustomers();
    var insertedRows = connection.InsertAll<Customer>(customers);
}
Enumeration

Organize your class lookups via enumerations. Learn more

using (var connection = new SqlConnection(connectionString))
{
    connection.QueryAll<Customer>(e => e.Gender == Gender.Male);
}
Trace

Audit, debug and control the current execution context prior to the actual execution. Learn more

public class CustomTrace : ITrace
{
    ...
}

using (var connection = new SqlConnection(connectionString))
{
    connection.Query<Customer>(c => c.CustomerId == 10045,
        trace: new CustomTrace());
}
Repository

Simplify the data access layers by leveraging the built-in repositories. Learn more

public class PersonRepository : BaseRepository<Person, SqlConnection>
{
    public PersonRepository(string connectionString) :
        base(connectionString) { }
}

using (var repository = new PersonRepository(connectionString))
{
    repository.Insert(person);
}

Bulk Operations

Bulk Insert

Brings all the data into the database in one-go via bulk insert. Learn more

using (var connection = new SqlConnection(connectionString))
{
    var customers = GenerateCustomers();
    connection.BulkInsert<Customer>(customers);
}
Bulk Merge

Migrates the big chunks of data back to database via bulk merge. Learn more

using (var connection = new SqlConnection(connectionString))
{
    var zipCodes = GetZipCodes();
    connection.BulkMerge<ZipCode>(zipCodes);
}
Bulk Update

Process all the changes at once using bulk update. Learn more

using (var connection = new SqlConnection(connectionString))
{
    var orders = connection.Query<Order>(e =>
        e.DateUpdated < DateTime.UtcNow.Date.AddDays(-1));
    connection.BulkUpdate<Order>(orders);
}
Bulk Delete

Remove the big chunks of data in one-go via bulk delete. Learn more

using (var connection = new SqlConnection(connectionString))
{
    var inactiveOrders = connection.Query<Order>(
        e => e.State == State.Inactive);
    connection.BulkDelete<Order>(inactiveOrders);
}