score:12

Accepted answer

you can do something like this:

public interface ientity<t>
{
    iqueryable<t> getall();
}

public class dealer : ientity<dealer>
{
   public iqueryable<dealer> getall() { }
}

score:1

adding save(), validate(), etc. logic to your domain object (which is what a dealer is, i guess) is not the best idea in the world as it violates srp.

score:3

you just need to make ientity generic itself. then, use the type parameter in the definition of getall().

here's how you'd change your code:

public interface ientity<tlistitemtype>
{
     // stuff snipped

     iqueryable<tlistitemtype> getall();
}

public class dealer : ientity<dealer>
{
   public iqueryable<dealer> getall() { // some impl here }
}

Related Query

More Query from same tag