your problem is that your method isn't generic, the class is. Notice there' no <T> after then method name, than mean you have to pass in an IQueryable of what ever was yoused for the type argument for the class.
E.g if the object was instantiated like this:
new BaseController<BaseObject>(..) //ignoring that BaseController is abstract
you'd need to pass an IQueryable<BaseObject> so in your case where you wish to pass in an IQueryable<Car> the type of controller needs to derive from BaseController<Car>
If on the other hand you wish the method to be generic change the signature of the method to
public IQueryable<TElement> FilterEntities<TElement>
(IQueryable<TElement> entities)
that does not include the type contraint on T you have on the type parameter for the class. If this is should be enforced for the generic method the signature needs to be:
public IQueryable<TElement> FilterEntities<TElement>(IQueryable<TElement> entities)
where TElement : BaseObj, new()
EDIT
If you wish to have a "default" method that simply uses T as the type argument you will have to implement it as a non generic method just as you have in your code so the class would be:
public abstract class BaseController<T> : ControllerBase
where T : BaseObj, new()
{
public IQueryable<T> FilterEntities(IQueryable<T> entities)
{
return FilterEntities<T>(entities);
}
public IQueryable<TElement> FilterEntities<TElement>(IQueryable<TElement> entities)
where TElement : BaseObj, new()
}
IQueryable<Car>, why would you make this method generic?BaseControllerbut I would try to avoid using them if possible. For example if you want to use normal controllers, web api controllers and async controllers in your project, you would need to then create three base controllers and duplicate some code. Instead you should look at Global or Controller level filters.