What is the unit of work pattern in EF?

后端 未结 3 1956
鱼传尺愫
鱼传尺愫 2020-12-24 01:18

I am learning EF and have seen many examples, and during my learning I came to know about using repository and unit of work patterns. I got why to use repository but I do no

3条回答
  •  温柔的废话
    2020-12-24 02:19

    One of the most common design patterns in enterprise software development is the Unit of Work. According to Martin Fowler, the Unit of Work pattern "maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems."

    The Unit of Work pattern isn't necessarily something that you will explicitly build yourself, but the pattern shows up in almost every persistence tool that I'm aware of. The ITransaction interface in NHibernate, the DataContext class in LINQ to SQL, and the ObjectContext class in the Entity Framework are all examples of a Unit of Work. For that matter, the venerable DataSet can be used as a Unit of Work.

    For more detail info Please click here to read this article, it's a good one.

    For Tutorial on Implementing the Repository and Unit of Work Patterns in an ASP.NET MVC (MVC 4 and EF 5) Application (9 of 10) please click here

    For EF 6 and MVC 5 tutorial please click here

    I hope this will help, it helped me!

    enter image description here

提交回复
热议问题