This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hello, I have problem with using two unit of work inside one MVC controllers. This is how my ControllerBase look like: public abstract class ControllerBase : Controller My controllers begins with: public class HomeController : ControllerBase which was working fine until I've added second unit of work to my ControllerBase class. Inside dbRepository I have all my data access functions and now when I'm accessing one of dbRepository functions I'mgetting this error: Unable to cast object of type 'Page.Models.stLightSpeedModelUnitOfWork' to type 'Page.Models.dbLightSpeedModelUnitOfWork'. any idea why I'm getting this error? Thanks |
|
|
Hi Webio, PerRequestUnitOfWorkScope is designed to only be used with a single typed unit of work as it stores its internal value into a constant under the HttpContext.Items collection. You will want to implement a custom version of UnitOfWorkScopeBase to handle this. A few customers have done this before, one of whom has shared him implementation here: http://www.mindscape.co.nz/forums/Thread.aspx?PostID=5406 You may be able to just run with his implementation as is and swap it in over your usage of PerRequestUnitOfWorkScope<> in the above class.
Jeremy |
|
|
This is great. Worked without problems. Thanks |
|