I have this generic method:
public void Send < TBiz, TEntity > (string serviceName, string pkName)
where TEntity: class, IEntity
where TBiz: class, BLL.Modules.INewSend
{
var biz = DependencyFactory.Get < TBiz > ();
var query = (biz.GetNotSent() as IEnumerable < TEntity > );
NewSender < TBiz, TEntity > (serviceName, pkName, query);
}
TEntity
is my data model objects (I mean model of DB tables) and can be of any types (like cars, humans, flowers and so on) but all of them have the ID
property. TEntity
implements IEntity
inteface. IEntity
is an empty interface or can be an interface that has only ID
implementation as below:
public interface IEntity
{
}
or
public interface IEntity {
public int ID {
get;
set;
}
}
TBiz is my business class that implements INewSend
. INewSend
is a simple interface that has 2 implementation:
public interface INewSend {
void Send(long id, string userName);
IEnumerable < IEntity > GetNotSent();
}
this code works fine but I am curious that in terms of Object Oriented Principles it is OK that TEntity
class inherits the IEntity
interface that is empty? I did this in order to pass different classes(all of these classes inherit the IEntity
interface) to the Send
method.
The IEntity
interface also can be an interface with an ID
property but I think it does not change the question because the entities that implements this interface are in completely different types though all of them have the ID
property.