I’m about to start working on the query side of the Rapid Repository as I think this will be the most important requirement for the next release (which I am hoping will come pretty soon).
My current plan is to do something fairly simple but I thought I’d publish the idea first in case any would prefer a different implementation.
Queries will be done against View Models.
A view model will be a simple class which implements an interface IRapidView (this will enforce that the entity id is captured within the view model class).
The view model will or should be a flattened subset of an entity, perfect for displaying on a page.
An example could be something like the following:
To setup the view, at application start up there will be a method similar to the following:
Also, I am proposing a filtering feature during setup where linq / lambda can be used to ensure the view filters out any unwanted data – it will look similar to the following:
Querying the View
Querying the View will be achieved through a method on the repository that will take the type of view as a generic parameter, this will return a (possibly cached) List<TViewType> that can be queried against using full Linq to Objects.
This will look similar to the following (lambda):
Why will this be any better than just loading all the entities?
There are a number of reasons why this would be better than getting all on an entity type (how the current release works).
The first being the fact that the view model will contain only the data required for the view, this immediately means less data in memory and less to de-serialise.
The other reasons will include how i intend to store, cache and load the View.
As a basic idea, I’m going to look at storing a view in one view file per type, and have that (optionally) load into the application cache on start up.
The view will then be synchronously managed in memory whilst asynchronously managed within isolated storage.
Anyway, as a really basic overview, that is my current plan, any thoughts, criticisms or ideas would be most welcome.
You can download the current release, source code and test windows 7 phone application from http://rapidrepository.codeplex.com/.