This is a migrated thread and some comments may be shown as answers.
ObjectScope lifetime
1 Answer 53 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alexey
Top achievements
Rank 2
Alexey asked on 16 Dec 2008, 11:00 AM
Hi,

For example I've got to repositories ProductRepository and EmployeeRepository they can add, delete, and get filtered collections of products and employees. They uses objectscope to do their operations.

What is the best place and time to create objectscope.

1. Per method of repository
2. Per instance of repository
3. Create objectscope before using of repositories and pass it via repository contructor.
4. Another way... =)

Cheers,
Alexey Zakharov.

1 Answer, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 16 Dec 2008, 03:35 PM
Hello Alexey,
It depends what you want to do.

In a web page it is best to get the scope if you need it and dispose it in the pages dispose method. In a app. server or fat client app you should complete your usecase and dispose the scope after you are done.

If you do not have such places you also can use the scope as singleton, but you should avoid using it in more then one thread at the same time.

Regards,
Jan Blessenohl
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Alexey
Top achievements
Rank 2
Answers by
Jan Blessenohl
Telerik team
Share this question
or