SisoDb – Simple tip on how to write more performant queries

Time for a really quick tip when it comes to queries in SisoDb that will give you better performance. When firing of a query with lots of parameters in your expression, move the logic into your model instead. That way the expression only has to lookup one index-value for your structure, and it will probably also state what you are doing. Example

session
    .Query<WorkOrder>()
    .Where(w => w.Status == WoStatus.Done || w.Status == WoStatus.Trashed);

should be

session
    .Query<WorkOrder>()
    .Where(w => w.IsClosed);

This was just a super simple example, but really. Try and get it down to one param. You will gain performance.

//Daniel

SisoDb now lets you query without transactions

Before v2.0 of SisoDb (http://sisodb.com) you could only query using an UnitOfWork. All UnitOfWorks are transactional and in some cases you might want to perform queries in the same transaction as you are doing inserts, updates and deletes in, but if you just want to query you should use the new QueryEngine class.

using(var qe = database.CreateQueryEngine())
{
    customers = qe.Where<Customer>(c => c.Lastname == "Andersson");
}

//Daniel