Of course, you can have an abstract general method:
public abstract class FilterBase { public abstract IQueryable<T> GetFilter<T>(IQueryable<T> query); }
The problem is that this does not mean what you want. It can be called for any T In particular, the following should work, since ProjectFilter comes from FilterBase :
FilterBase fb = new ProjectFilter(...); IQueryable<string> query = ...; IQueryable<string> filter = fb.GetFilter<string>(query);
So FilterBase cannot just implement GetFilter<Linq.Project> . It should implement GetFilter<string> , GetFilter<int> , etc .; in short, GetFilter<T> . Therefore, you can see that this is not a limitation.
Alexey romanov
source share