开发者

Insert/Update/Delete of EF in Business layer

开发者 https://www.devze.com 2023-02-16 00:22 出处:网络
I can\'t live with the idea that we need to rec开发者_StackOverflowreate the insert/update/delete functionality in ALL pocos/bl objects? EF and linq2sql that have this so nice built in by itself.

I can't live with the idea that we need to rec开发者_StackOverflowreate the insert/update/delete functionality in ALL pocos/bl objects? EF and linq2sql that have this so nice built in by itself.

How do you guys solve this on a effective way? Using a base class or some magic in the IQueryable pocos?

.NET 4


Since your Entity Framework / Linq objects are probably inherited from some base class you can inherit the objects in your business layer from a single base class. Then do something like this:

public class BusinessBaseCollection
{
    protected EFBaseCollection _efObject = null;

    public BusinessBaseCollection(EFBaseCollection efObject)
    {
        _efObject = efObject;
    }

    public Add(BusinessBase obj)
    {
        _efObject.Add(obj);
    }

    //Add other CRUD stuff here
}
0

精彩评论

暂无评论...
验证码 换一张
取 消