This project is read-only.

CustomORM is tiny ORM system written in .NET. CORM is slightly bigger than so-called micro-ORMs and much smaller than NHibernate. It has its uniqueness.

Features at glance:

  • POCO (real POCO without any “virtual” constraints or attributes)
  • Mapping much like FluentNH
  • Very light, thus faster
  • No syntaxes to learn (nothing like complex criteria or another version of sql)
  • Source code in your project you can debug, and change quickly

There are few things I want this project to be:

  • The lighter - the better
  • POCO as a must
  • Customizable at the lower data access level
  • Rather source code in your project, not reference

Now, let me show you some code

Sample fetch

Here is how select works:

            Criteria criteria = CreateCriteria(typeof(Customer), "c")
                .AddEntity(typeof(Order), "o")
                .AddEntity(typeof(Employee), "e")
                        @"left join Orders o
                        on c.[Customer ID] = o.[Customer ID]
                        left join Employees e
                        on e.[Employee ID] = o.[Employee ID]
                        where c.[Customer ID] = @customerId")
                .AddParameter("@customerId", customerId);

            List<Customer> customers = ExecuteCriteria<Customer>(criteria);

As you can see you add type of entity to take part in join, assign alias to it and then write old known SQL. In the end you get nice collection of objects. No root transformations to be applied.

Sample save

Here is code you might write for the save:

        public Customer SaveCustomer(Customer customer)
            var transaction = BeginTransaction();

            Customer savedCustomer = null;
                savedCustomer = Save(customer);
            catch (Exception)
            return savedCustomer;


All this above will work after small setup and mappings for your objects.

    class CustomerMap : EntityToTableMapper<Customer>
        public CustomerMap()
            Id(x => x.CustomerID, "Customer ID")
            Map(x => x.CompanyName, "Company Name");
            Map(x => x.ContactName, "Contact Name");
            Map(x => x.ContactTitle, "Contact Title");
            Map(x => x.City, "City");
            HasMany(x => x.Orders, "Customer ID");

Get started code

To get started all setup you need is basically two things: derive you own Repository class from RepositoryBase and add bootstrap code at start of your app similar to this:

// Let CORM know where your mappings live and that's mostly it

// Initialize AdoDataAccess or (advanced) implement your own IDataAcces 
var s = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"];
var ceDataAccess = new AdoDataAccess(s.ConnectionString, s.ProviderName);

// You are ready to use you repository, it already has Fetch<T>, Save, Delete var customerRepository = new CustomerRepository(ceDataAccess);

Hope it doesn’t look like much code.



As for now I have CRUD operations tested on Northwind SqlCe database. I verified that fetching 91 customers (2000 db records) is 2-3 times faster than NHibernate.

Project still lacks very much in transactions/sessions/concurrency and completely doesn’t have caching (I don’t think it should ever have).

Project has bad code coverage and probably isn’t ready for community review until I polish it. But anyway sharing this with you because someone has to kick-me-off.

If you still would like to take a look at some code please start with CustomORM.Examples => Program for usage code and for engine code go to CustomORM where most of the heavy logic lives in RepositoryBase and EntityToTableMapper.

Depending on feedback and my mood I will decide if it worth investing more of mine time or not.

Last edited Nov 29, 2011 at 5:24 AM by andriybuday, version 8