Question

I'm just starting with SubSonic 3 and playing with the SimpleRepository approach. What's the intended lifetime of SimpleRepository classes when used in a desktop application?

Are you expected to keep creating a new instance for everytime you want to touch the database? Should I create an instance to use for each group of database calls that happen together? Should I create one singleton instance when the program starts and use it for everything?

I'm assuming it's one of the second two options, but it's not clear to me if it would be safe to create a single instance and use it for all calls or not. I'll be using an IoC container if that matters.

Was it helpful?

Solution

There's no harm in keeping the thing alive for the length of the desktop session (make sure you turn off the migration stuff). When I perf-tested the repo I kept one open the whole time and I didn't see any issues with memory leaks - but be sure to close off any readers if you execute them etc etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top