ORM-Micro

Easiest and fastest Micro ORM, you've got the queries, you've got the objects, take the best of two worlds !

Now available on NuGet by searching ORMMicro

Why another Micro ORM ?

Like many others dev, I've got the competences in writing database requests. So why should I learn and use another language (LinQ for example), when i can write and optimize it myself ?

The only thing I want is focus on datas, instead of loosing time on plumbing and transformations ;)

How to use it ?

Just reference both the main library and the provider-based library you want to use on your project. For more information, open the samples, and learn by experiment.

To quickly understand, just read that sample :

// We have a some Models for working with Languages and Users
public class LanguageModel
{
    public Guid LanguageId { get; set; }
    public string LanguageName { get; set; }
    public string LanguageCulture { get; set; }
}

public class UserModel
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Address { get; set; }
    public DateTime BirthDate { get; set; }
    public double Money { get; set; }
    public Guid LanguageId { get; set; }
}

// We write the request, and get the objects from it automagically
public override List<LanguageModel> GetLanguages()
{
    List<LanguageModel> languages;

    var languageQuery = @"
        select	l.lanId as LanguageId,
                l.lanName as LanguageName,
                l.lanCulture as LanguageCulture
        from Language l (nolock)
        where l.lanCulture like @SearchedCulture
        order by l.lanName";

    using (var context = new DataContext(ConfigurationManager.ConnectionStrings["YourConnString"].ConnectionString))
    {
        // You can add parameters by using dynamic DataContextBag :
        context.DataContextBag.SearchedCulture = "%en%";
        languages = context.ReadEntities<LanguageModel>(languageQuery).ToList();
    }

    return languages;
}

// We write the insert, and inject parameters automagically
public int CreateUserTest()
        {
            var user = new UserModel {Name = "John Smith", Address = "135 Street Avenue, City, State", BirthDate = new DateTime(1950, 1, 1), Money = 12056.25};

            const string createStatement = @"
                insert into User(UserFirstName, UserLastName, UserAddress, UserBirthDate, UserAccountMoney)
                values(@FirstName, @LastName, @User.Address, @User.BirthDate, @User.Money)";

            object userIdCreated;

            using (var context = new DataContext(_connectionString))
            {
                context.DataContextBag.FirstName = "John";
                context.DataContextBag.LastName = "Smith";
                context.DataContextBag.User = user;
                context.CreateEntity(createStatement, out userIdCreated);
            }

            return userIdCreated;
        }

You've got many ideas ?

Cool ! Please feel free to comment, add some providers, correct some misspellings, feed the dog... You'll always be welcome ;)

Last edited Nov 23, 2012 at 6:55 AM by Arsenikstiger, version 6