Repository Generic, Session and Transaction how to do ? RRS feed

  • Question

  • Hi,

    I developed a generic repository for manage my entity.

    Now in some case I must to manage the session and transaction and only to end of data processing I can to save the data in DataBase.

    In this context can I integrate the managing the transaction in generic repository or I must managing in different mode?

    In general in the context where must manage transaction and session, what is the best way to follow?


    Thursday, April 21, 2016 9:18 AM


  • Hi cicciuzzo2000,

    According to your description, you need to manage the session and transaction and only at the end of data processing you could save the data in Database, it seems that unit of work meets your requirements. The unit of work represents a transaction when used in data layers. Typically the unit of work will roll back the transaction if SaveChanges() has not been invoked before being disposed, for more information, please refer to the following links.



    Note: This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. 

    Microsoft does not control these sites and has not tested any software or information found on these sites;Therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.

    There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.

    Best regards,

    Cole Wu

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 22, 2016 4:36 AM