Question

I used Entity Framework 4.0 for creating my Data Access Layer. Then I found that my Business Logic Layer has the same objects as DAL but with some extensions (i.e, more properties, some functions, and data validation at setters...).

I planned to have DAL and BLL in separate projects and was looking for best practice to use entity classes in BLL and prevent redundancy in code.

As I searched and there are two major ideas:

  1. extending entity classes inside the same project by partial classes
  2. Using interfaces (implemented by entity class and relevant BLL class). Former is more popular among programmers.

Disadvantages for above solutions:

  1. We need to add the code at the same project as part of the partial class. This is good for adding properties and methods but it's not good for overriding something (i.e, adding validations before setting a property at Business Logic Layer)
  2. If the entity model is changed, we need to manually extract the interfaces from entity classes again and also another change in BLL related class is needed (two manual work around).

My question is why we simply doesn't inherit our BLL classes from relevant entity classes and extend/override their methods and properties ?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top