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 all, I'm developing an application for enterprise management. I thought to implement the MVC pattern to ensure a high degree of order in the project. I created a base controller, where I inserted the LightSpeedContext variable. All controllers inherit from the base controller. Each controller has a public variable called MODEL ( so Views->Forms can bind against), which is reset for each new transaction. I have read your documentation and your advice and I realized that the unit of work must be short-lived to ensure an excellent operation of the software. So every method of the controller (create, delete, edit, ect) creates a new UOW and attach the private variable MODEL (previously valued) to perform the requested operation, then performs the UOW dispose. It works, i dont know if it is the best way to go, but works ( I accept suggestions on how to improve it ) to be more understandable I post the source code of the controller base
As you can see, the controller has a method called LIST. This method return a list of records in the database for that model, then i bind it to a BindingSource and bind it to a DataGridView This function generates an error because when you return the list to the view (form) it claims that the list should be combined with a unit of work (which I have disposed, to ensure that the UOW be short-lived) I know the ways to solve the problem, but I would like to know your opinion :) The best way to solve this ? Maybe my approach is wrong ! I hope I have been clear, and I apologize for my bad English ask me for more information if necessary |
|
|
You will need the UnitOfWork to be scoped on a per request basis (disposed at the end of each request) so that entities loaded by your controller but which are accessed by your view or associated controls dont try and interact with a disposed UOW instance. Have a read through http://www.mindscapehq.com/documentation/lightspeed/Building-Web-Applications-/Building-ASPNET-Web-Forms-Applications as we make some recommendations there about how to manage your UOW to achieve this scoping.
|
|