Auditable Database Context

Handles automatic inserting of date and time for create or modify as well as performer of the task.

var order = new Order { Id = Guid.NewGuid(), Description = "Sample Order", OwnerId = client.Id };
using (var db = new AppDbContext())
{
    db.Orders.Add(order);
    db.SaveChanges();

    IAudit auditOrder = order as IAudit;
    Console.WriteLine(auditOrder.CreatedOn);
    Console.WriteLine(auditOrder.CreatedBy);
}

Bulk Insert Operation

High speed insertion of new records with a single statement.

var clients = new List<Client>();

clients.Add(new Client { Id = Guid.NewGuid(), Names = "John Smith", Address = "24 Iwat street", Email = "jsmith@xyz.com", PhoneNo = "012345678" });
clients.Add(new Client { Id = Guid.NewGuid(), Names = "Mary Atkin", Address = "11 Gent street", Email = "maryki@xyz.com", PhoneNo = "283942943" });
clients.Add(new Client { Id = Guid.NewGuid(), Names = "Sammy Doe", Address = "33 Rock street", Email = "sammydo@xyz.com", PhoneNo = "103948392" });
clients.Add(new Client { Id = Guid.NewGuid(), Names = "Aki Matsui", Address = "98 Yoga street", Email = "akimat@xyz.com", PhoneNo = "495849382" });

using (var db = new AppDbContext())
{
    db.Insert(clients);
}

Batch Update/Delete Operation

Batch update/delete of records using a member initialization expression.

using (var db = new AppDbContext())
{
    // Batch update
    db.Clients.Where(c => c.Names.StartsWith("Aki")).Update(
        c => new Client
        {
            Names = "Akiyu"
        });

    // Batch delete
    db.Clients.Where(c => c.Names.Contains("Mary")).Delete();
}

Simple Settings storage

Application Configurations can be stored and retrieved seamlessly.

using (var db = new AppDbContext())
{
    // Requires a minimum of two parameters: Name and Caption
    // Name is the unique identifier of the setting.
    // Caption is the friendly name that may appear in your configuration form.
    db.GetOrAddSetting<string>("AppTitle", "Application Title");    // default value is null
    db.GetOrAddSetting("BatchSize", "Batch Size", 20);              // value is 20

    var title = db.GetSetting<string>("AppTitle");
    var batchSize = db.GetSetting<int>("BatchSize");

    Console.WriteLine(title);
    Console.WriteLine(batchSize);
}

Dynamic Filters Operation

Filters allows application to automatically apply filter to queries, which can be used for multi-tenancy, soft deletes etc. There are two types of dynamic filters: Global and Scoped filters.

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
    base.OnModelCreating(modelBuilder);

    #region Filters

    modelBuilder.Filter(DynamicFilterKeys.CurrentDomain, (IDomain entry) => entry.TenantId,
        (ApplicationDbContext context) => context.CurrentDomain?.TenantId);

    #endregion
}

Multi-Tenancy Operation

Tenancy allows application be shared by multiple clients while the database appear unique to each clients. There are basically three types of database tenancy, Shared Key, Schema and Isolation, two of which are currently support ( Shared Key and Isolation).