C# – Generic list in an interface

c++generic-listgenericslinq

I am trying to implement an interface class, that contains a list of objects. How can I make the list generic, so that the implementing class defines the type of list:

public interface IEntity
{
    Guid EntityID { get; set; }
    Guid ParentEntityID{ get; set; }
    Guid RoleId { get; set; }

    void SetFromEntity();
    void Save();
    bool Validate();
    IQueryable<T> GetAll(); // That is what I would like to do
    List<Guid> Search(string searchQuery);
}
public class Dealer : IEntity
{
   public IQueryable<Dealer> GetAll() { }
}

Best Solution

You can do something like this:

public interface IEntity<T>
{
    IQueryable<T> GetAll();
}

public class Dealer : IEntity<Dealer>
{
   public IQueryable<Dealer> GetAll() { }
}