MicroLite Comparison Feedback pt2

Following on from yesterdays post, I wanted to address this comment separately:

“PetaPoco just “feels” simpler to use and less like the clunky Spring/Hibernate syntax I wanted to avoid. But it doesn’t appear to be actively maintained. Then again, there are 500+ hits on Stackoverflow (always a useful measure 😉 ) for PetaPoco, and 6 for MicroLite.”

Ignoring the configuration element to MicroLite which we discussed in yesterdays post, how does it differ getting our database access?

// MicroLite
using (var session = sessionFactory.OpenSession())
{
    ...
}

// PetaPoco
using (var database = new Database("sqlite"))
{
    ...
}

OK, they’re pretty similar. How about using a transaction?

// MicroLite
using (var transaction = session.BeginTransaction())
{
    ...
    transaction.Complete();
}

// PetaPoco
using (var transaction = database.GetTransaction())
{
    ...
    transaction.Complete();
}

Again, almost identical.

Something that MicroLite offers is the option to override the IsolationLevel which by default is ReadCommitted.

// MicroLite
session.BeginTransaction(IsolationLevel.Serializable))

PetaPoco provides an alternative method for managing the transaction although I’m not sure what the difference is between them or why you need 2 ways to do the same thing.

// PetaPoco method 2
database.BeginTransaction();
...
database.CompleteTransaction();

Overall so far things are pretty similar. So how about the common methods used in most applications?

MicroLite 4.0.1
Delete Delete(object instance)
Delete(Type type, object identifier)
Insert Insert(object instance)
InsertOrUpdate(object instance)
Select (single) Single<T>(object identifier)
Single<T>(SqlQuery sqlQuery)
Select (many) Fetch<T>(SqlQuery sqlQuery)
Paged<T>(SqlQuery sqlQuery, PagingOptions pagingOptions)
Projection(SqlQuery sqlQuery)
Update Update(object instance)
InsertOrUpdate(object instance)
PetaPoco 5.0.1
Delete Delete(object poco)
Delete(string tableName, string primaryKeyName, object poco)
Delete(string tableName, string primaryKeyName, object poco, object primaryKeyValue)
Delete<T>(object pocoOrPrimaryKey)
Delete<T>(string sql, params object[] args)
Delete<T>(Sql sql)</code
Insert Insert(object poco)
Insert(string tableName, string primaryKeyName, object poco)
Insert(string tableName, string primaryKeyName, bool autoIncrement, object poco)
Save(object poco)
Save(string tableName, string primaryKeyName, object poco)
Select (single) Single<T>(object primaryKey)
Single<T>(string sql, params object[] args)
Single<T>(Sql sql)
SingleOrDefault<T>(object primaryKey)
SingleOrDefault<T>(string sql, params object[] args)
SingleOrDefault<T>(Sql sql)
First<T>(string sql, params object[] args)
First<T>(Sql sql)
FirstOrDefault<T>(string sql, params object[] args)
FirstOrDefault<T>(Sql sql)
Select (many) Fetch<T>(string sql, params object[] args)
Fetch<T>(Sql sql)
Fetch<T>(long page, long itemsPerPage, string sql, params object[] args)
Fetch<T>(long page, long itemsPerPage, Sql sql)
Fetch<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, string sql, params object[] args)
Fetch<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, Sql sql)
Fetch<T1, T2, T3, T4>(string sql, params object[] args)
Fetch<T1, T2, T3, T4>(Sql sql)
Fetch<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, string sql, params object[] args)
Fetch<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, Sql sql)
Fetch<T1, T2, T3>(string sql, params object[] args)
Fetch<T1, T2, T3>(Sql sql)
Fetch<T1, T2, TRet>(Func<T1, T2, TRet> cb, string sql, params object[] args)
Fetch<T1, T2, TRet>(Func<T1, T2, TRet> cb, Sql sql)
Fetch<T1, T2>(string sql, params object[] args)
Fetch<T1, T2>(Sql sql)
Page<T>(long page, long itemsPerPage, string sqlCount, object[] countArgs, string sqlPage, object[] pageArgs)
Page<T>(long page, long itemsPerPage, string sql, params object[] args)
Page<T>(long page, long itemsPerPage, Sql sql)
Page<T>(long page, long itemsPerPage, Sql sqlCount, Sql sqlPage)
Query<T>(string sql, params object[] args)
Query<T>(Sql sql)
Query<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, string sql, params object[] args)
Query<T1, T2, T3, T4, TRet>(Func<T1, T2, T3, T4, TRet> cb, Sql sql)
Query<T1, T2, T3, T4>(string sql, params object[] args)
Query<T1, T2, T3, T4>(Sql sql)
Query<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, string sql, params object[] args)
Query<T1, T2, T3, TRet>(Func<T1, T2, T3, TRet> cb, Sql sql)
Query<T1, T2, T3>(string sql, params object[] args)
Query<T1, T2, T3>(Sql sql)
Query<T1, T2, TRet>(Func<T1, T2, TRet> cb, string sql, params object[] args)
Query<T1, T2, TRet>(Func<T1, T2, TRet> cb, Sql sql)
Query<T1, T2>(string sql, params object[] args)
Query<T1, T2>(Sql sql)
Query<TRet>(Type[] types, object cb, string sql, params object[] args)
SkipTake<T>(long skip, long take, string sql, params object[] args)
SkipTake<T>(long skip, long take, Sql sql)
Update Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue)
Update(string tableName, string primaryKeyName, object poco, object primaryKeyValue, IEnumerable columns)
Update(string tableName, string primaryKeyName, object poco)
Update(string tableName, string primaryKeyName, object poco, IEnumerable columns)
Update(object poco, IEnumerable columns)
Update(object poco)
Update(object poco, object primaryKeyValue)
Update(object poco, object primaryKeyValue, IEnumerable columns)
Update<T>(string sql, params object[] args)
Update<T>(Sql sql)
Save(object poco)
Save(string tableName, string primaryKeyName, object poco)

MicroLite has 2 methods for Delete, Insert, Select Single & Update and 3 for Select Many (arguably 2 since Projection has been obsoleted in favour of using Fetch<dynamic>).

PetaPoco however has 6 for Delete, 5 for Insert, 10 for Select Single, 12 for Update and a ridiculous 37 for Select Many! Maybe not simpler after all.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s