ObjectScope lifetime

Thread is closed for posting
2 posts, 0 answers
  1. Alexey
    Alexey avatar
    79 posts
    Member since:
    Oct 2008

    Posted 16 Dec 2008 Link to this post


    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... =)

    Alexey Zakharov.
  2. Jan Blessenohl
    Jan Blessenohl avatar
    707 posts

    Posted 16 Dec 2008 Link to this post

    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.

    Jan Blessenohl
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top