Actually, the way you decide to go is the reason that you have (I'm not saying that this is bad).
First, let me say that your approach is quite normal.
Now let me think about your layers:
- Your service - provides several types of strictly typed access models. This means that it has some types of arguments used in some special types of methods, which again return some particular type of results.
- The level of access to the service also provides the same model. So it takes special arguments for special kinds of methods, returning special kinds of results.
- etc...
In order not to be confused, this is what I call a special kind:
public UserEntity GetUserByID(int userEntityID);
In this example, you need to pass exactly Int, while GetUserByID is called, and it will definitely return a UserEntity object.
Now a different approach :
Remember how SqlDataReader works? not very strongly typed, is it? In my opinion, you call this the fact that you are missing some kind of not strictly typed layer.
For this to happen: you need to switch from strongly typed to not strongly typed somewhere in your layers.
Example :
public Entity SelectByID(IEntityID id); public Entity SelectAll();
So, if you have something like this instead of the level of access to the service, you can call it for any arguments that you wanted.
But this almost creates its own ORM, so I don't think this is the best way to go.
source share