views:

99

answers:

1

Is it possible to get a LINQ to SQL DataContext to run completely in-memory? Without it touching the database?

I am doing some very rapid prototyping, and want to minimize the surface area for major changes since the UI is changing so fast. However, the data model already exists.

Data access is handled through the use of I[Model]Repository classes that return the actual LINQ to SQL data classes, so I currently have some concrete InMemory[Model]Repository classes that shove stuff in cache. The implementation is a little cumbersome however.

So... is it possible to simply override enough of the DataContext behavior to have it run in-memory and never touch the database. My assumption is that it is not possible, but I thought I would go fishing anyway.

+1  A: 

You can only do this if you are prepared to wrap access to the datacontext with your own interface. Then for rapid prototyping you can write your own datacontext alternative that implements this interface and instead uses lists and LINQ to Objects to perform in-memory queries.

DamienG
Yeah that is what I figured. I am wrapping the access to DataContext up behind repository interfaces in order to hide the implementation details to the presentation layer, but I was hoping for something easier.
Josh