Odata Generic Controller not treated as odata controller in ver 8.0
Open
@xuzhg is already working on this.
Since Mar 2, 2021.
followup
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
We have upgraded our aspnetcoreodata 7.4 to 8.0 beta. After upgrade our generic controller not treated as odata controller and all the count/expand/select not working.
To Reproduce
in Startup
services.AddOData(options => options.Count().Filter().Expand().Select().OrderBy().SetMaxTop(100)
.AddModel("odata", GetEdmModel(), new DefaultODataBatchHandler())
);
services.AddMvcCore()
.ConfigureApplicationPartManager(m => m.FeatureProviders.Add(new GenericFeatureProvider()))
In GenericFeatureProvide
var typeName = entityType.Name + "Controller";
if (!feature.Controllers.Any(t => t.Name == typeName))
{
var controllerType = typeof(GenericController<>)
.MakeGenericType(entityType)
.GetTypeInfo();
feature.Controllers.Add(controllerType);
}
In GenericController
[GenericControllerName]
////[EnableQuery(MaxNodeCount = 10000, AllowedQueryOptions = AllowedQueryOptions.All, MaxExpansionDepth = 4)]
public class GenericController<T> : ODataController where T : EntityModel
{
protected IEntityRepository<T> EntityRepository { get; set; }
public GenericController(IEntityRepository<T> EntityRepo, IConfiguration configuration)
{
EntityRepository = EntityRepo;
}
[HttpGet]
public async Task<IQueryable<T>> Get()
{
var res = await EntityRepository.GetItemsEnumerableAsync(c => (!c.IsActive || IncludeIsActive));
return res.AsEnumerable().AsQueryable();
}
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.