Base solution for your next web application
Open Closed

How to reuse the existing interface? #4863


User avatar
0
manojreddy created

I have some model classes.

public class AClass : FullAuditedEntity<int>
{

}

and one interface like below.

public interface ISomeInterface<T, TEntity> where T : BaseFileEntity where TEntity : class, IEntity<int>
{

}

Now If I add one extra model class like below.

public class BClass : FullAuditedEntity<string>
{

}

I have to define another interface for this change like below.

public interface ISomeInterface<T, TEntity> where T : BaseFileEntity where TEntity : class, IEntity<string>
{

}

So basically it's duplicate code. Is there any better way to do this?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    You can define your interface something like this;

    public interface ISomeInterface<T, TEntity, TPrimaryKey> where T : BaseFileEntity where TEntity : class, IEntity<TPrimaryKey>
    {
    
    }