The Repository Pattern and SimpleDB

Sep 22, 2010 at 4:34 PM

I'm building up my ASP.Net MVC experience and am trying to be faithful to the approach and make my data access as separated out as possible - in particular by making access to model data as generic as I can (like Repository<Model>.GetById(id)) rather than having the specific data provider (Savant) in between. Have you done any coding in this direction already? I want to make sure I leverage whatever abstractions Savant already provides before coding off in some direction.
I'm particularly wondering if I can find a generic Repository pattern universal to ASP.Net that supports LINQ, but it seems from what I can find ASP.Net isn't that far along yet.
Any advice appreciated!

Sep 22, 2010 at 5:30 PM

No, I've not done any work to explicitly support the data repository pattern with Savant. I would argue that Savant itself provides some of the benefits of that pattern, in that you can load and store arbitrary data entities just by providing a type parameter.

I actually started down the road of putting all Savant access behind a data manager/repository class as I would with a SQL database and later backed out much of that code in my own app. The reason is that there are many SimpleDB interactions where asynchronous calls are necessary to achieve SQL-like performance. Since you can't perform joins, unions, aggregation, etc. with SimpleDB and get everything you need in a single database call you need to make parallel calls against the same or multiple domains. Putting a data layer between Savant and your service classes forces you to re-implement much of the async support that is already in Savant in your data classes.

So I ended up with a hybrid model where I use Savant directly when performing simple puts and gets, but place select queries or aggregation logic in a data manager/repository class specific to each data entity or set of related entities.