I have a base API Controller, here is a snippet:
public abstract class CrudController<TDto, TAdd, TEdit, TLookup> : BaseApiController
where TDto : BaseDto, new()
where TAdd : BaseModel
where TEdit : BaseModel
where TLookup : BaseModel
protected virtual Expression<Func<TDto, bool>> CreateWhere(Guid? id)
return dto => true;
public virtual DataSet<TLookup> Query([FromUri] DtoQuery query, Guid? id = null)
DataSet<TDto> data = DataService.Query(query, CreateWhere(id));
return new DataSet<TLookup>(data.Records.Map<TLookup>(), data.Total);
I inherit from this ApiController class, and then want to override a single method, within the derived class:
public class ProductCategoryController : CrudController<ProductSubcategoryDto, ProductSubcategoryModel, ProductSubcategoryModel, ProductSubcategoryModel>
protected override Expression<Func<ProductSubcategoryDto, bool>> CreateWhere(Guid? id)
return dto => dto.ProductCategoryGuid == id;
But the method in the derived class is not being executed.
GET api/productcategorycontroller/query?queryetctectec is called from the view.
DataSet<>() is executed on the base class.
I then step through the code, the first line of this method calls CreateWhere() and F11 takes me a few lines up and not to the overridden method in the derived class.
BaseApiController is just an empty class that is derived from ApiController.
Turns out I was breaking on the wrong ApiController, and it was working all along.