IvyORM

IvyORM is an extremely simple yet powerful ORM/Micro-ORM/MicroORM that extends DbConnection and DbTransaction. With IvyORM boilerplate code is reduced while keeping SQL a first class citizen.

Can be installed searching NuGet for IvyORM
Change History

Goals:

  • Simple Interfaces - The library is designed to be extremely easy to use by providing Insert, Update, Delete, Select and Execute as extensions to the DbConnection and DbTransaction types.
  • Reliable - IvyORM has been developed with reliability in mind and the library has extensive unit tests with 100% code coverage.
  • SQL is a First Class Citizen - Unlike other ORM solutions SQL is treated as a first class citizen with a direct SQL interface for all select and execute statements. A simple cross database parameter syntax is provided implemented similarly to the String.Format() command.
  • Multiple Database Support - Supports and has been tested with SQL Server, SQL Server Compact Edition, Oracle, SQLite, Firebird. Although there are some cases where provider specific tweaks were added most functions are written generally and leverage the standard ADO.NET providers and will work with other databases.
  • Uses Simple Object - All commands work with POCO object with attributes where necessary.

Example

using IvyOrm;
using System.Data.SQLite;
using System.Diagnostics;

namespace Example
{
    class Person
    {
        [PrimaryKey(PrimaryKeyOptions.ReturnKeyValueOnInsert)]
        public int PersonID { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }

    class Test
    {
        public void ExampleMethod()
        {
            //Supports any ADO.NET DbConnection
            using (var connection = new SQLiteConnection("...")) 
            {
                connection.Open();

                //Execute any Arbitrary SQL
                connection.ExecuteNonQuery("delete from TableA where ColumnA = @1", 12);

                //Insert records
                Person person = new Person { FirstName = "John", LastName = "Smith" };
                connection.RecordInsert(person);
                Debug.Assert(person.PersonID != 0); //PrimaryKey's value is returned

                //Selects an array
                Person[] people = connection.RecordQuery<Person>("select * from Person");

                //Select a single record
                person = connection.RecordSingle<Person>(@"select * from Person 
                                                           where LastName=@1", "Doe");

                //Updates
                person.LastName = "Roe";
                connection.RecordUpdate(person);

                //Executes a delete based off the primary key
                person = new Person { PersonID = 10 };
                connection.RecordDelete(person); 
            }
        }
    }
}

Last edited May 28, 2013 at 4:42 PM by gregweb, version 13