开发者

ADO.NET EF as DAL

I'm developing a project using a layered architecture. I have a DAL in which i'm using Entity Framework, a开发者_StackOverflow business logic layer which consumes the objects returned by the DAL and an app layer.

I'm not entirely sure i'm thinking this right, so i'll just ask you what you think.

My DAL is based on mappers. I have types - mappers - that the BLL uses to operate on my data. These mappers return DTO's, because i did not want to expose to my BLL any EF objects so their implementations are not dependent on EF to work.

All these mappers do are CRUD actions on a single 'table', like:

using (var contex = new EFEntities()){
  var obj = (from x in context.Table where x.ID == param select x).SingleOrDefault;
  return Map(x.ToList());
}

The Map method maps the EF object to a DTO, which has only some properties to map the values i want to expose.

Is there a more elegant approach to this? I am just using EF to facilitate the access to my database - i don't have to write any ADO.NET code.

Any input on this would be welcome.

Thanks.


I have a DAL in which i'm using Entity Framework, a business logic layer which consumes the objects returned by the DAL and an app layer.

That is a perversion, given that you are putting a complete object layer into your DAL. EF is a lot more than a DAL.

a business logic layer which consumes the objects returned by the DAL and an app layer.

The term you may want to look up for that is "anemic object model", and it is not a nice term.

Is there a more elegant approach to this?

Don't fight EF. if you dont like it, don't use it - there are a LOT better frameworks around.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜