I have a question about what to do with a entity that is not a representation of the data in the database, but a custom made entity that I need for business purposes.
My solution is structured in:
- Entities assembly (POCO objects)
- Repository assembly (EF Code First)
- Business layer assembly
- UI Assembly (MVC)
In my entities assembly I have two entities, A
and B
, and for a specific purpose of my business logic, I need to return an object that contains both (among other properties):
class X
{
public A[];
public B[];
}
Should I return this object directly from the repository? Or should the business layer call to repo.GetA
and repo.GetB
and then create X
and return it?
In this case, maybe it makes sense to create the object in the business layer. But what if the X
class was a "group by" of A
and B
? then returning it from the repository makes more sense.
I guess there is no silver bullet, but are there any guidelines?
Cheers.