Wednesday, 18 September 2013

SQLiteNet Index and Lambda expressions

SQLiteNet Index and Lambda expressions

We are using Xamarin with SQLiteNet as ORM.
In our data layer class we have the method below.
filter = ri => ri.ItemVersioniId == itemVersionId;
The method is getting the records matching the Id. If the lambda
expression is hardcoded, instead of using the "filter" parameter it is
much faster... even though it is the same logic.
We would to be able to pass the filter as a parameter but still get a good
performance. Any advise?
public virtual List<ResourceItem> GetResourceItems (string itemVersionId,
Func<ResourceItem,bool> filter ){
//var t = db.Table<ResourceItem> ().Where (ri => ri.ItemVersionId
== itemVersionId); --* this line is 10 times faster
var t = db.Table<ResourceItem> ().Where (filter); --* this line is
10 times slower
return new List<ResourceItem> (t);
}

No comments:

Post a Comment