EF6 (code first), MVC, Unity, and a service layer without a repository

前端 未结 4 1798
没有蜡笔的小新
没有蜡笔的小新 2021-02-09 00:11

My application is using SQL Server 2012, EF6, MVC and Web API.

It\'s also using a repository and assorted files such as:

DatabaseFactory.cs
Disposable.c         


        
4条回答
  •  别跟我提以往
    2021-02-09 00:40

    If you aren't using a repository then I assume you would have some place to write your logic/processing that your service operation would use. I would create a new instance of the Context in that logic/process class method and use its methods directly. Finally, dispose it off right after its use probably under a "using".

    The processing method would eventually transform the returned/processed data into a data/message contract which the service returns to the controller.

    Keep the data logic completely separate from Controller. Also keep the view model separate from data contract.

提交回复
热议问题