Hi, I followed the documentation to provide an oData Web API for one of the entities.
- I installed the Abp.Web.Api.oData nuget onto the WebApi project
- Added dependency to AbpWebApiOdataModule onto the WebApi module
[DependsOn(typeof(AbpWebApiModule), typeof(OnlineSystemsApplicationModule), typeof(AbpWebApiODataModule))]
public class OnlineSystemsWebApiModule : AbpModule
{
public override void PreInitialize()
{
var builder = Configuration.Modules.AbpWebApiOData().ODataModelBuilder;
//Configure your entities here...
builder.EntitySet<PersonofConcern>("PersonofConcern");
}
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
//Automatically creates Web API controllers for all application services of the application
Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
.ForAll<IApplicationService>(typeof(OnlineSystemsApplicationModule).Assembly, "app")
.Build();
Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
}
}
}
- Then created a new Controller: PersonofConcernController inside the Controllers folder:
public class PersonofConcernController : AbpODataEntityController<PersonofConcern>
{
public PersonofConcernController(IRepository<PersonofConcern> repository)
:base (repository)
{
}
}
When I run the application as <a class="postlink" href="http://localhost:8080/odata/PersonofConcern">http://localhost:8080/odata/PersonofConcern</a> in the browser,
I get all json data of all records in DB but not all columns are returned, only a few subset.
Where shall I look into this?
Thanks
12 Answer(s)
-
0
Hi,
Can you share your entity ? How many fields do you have in it ?
Thanks.
-
0
The entity I am using contains many fields more than 30. It is a single form that all data are related and hence I had to place them all in one entity.
More info is needed from my side?
Thanks
-
0
Hi,
ABP supports oData but we don't have deep information about it. Does it return all fields when you try with pure oData ?
Thanks.
-
0
I just followed the documentation you have on this topic. Part of the fields are returned but not all. Mostly all fields created by Abp like Creation... and 1 property from my entity.
This is what I've added on the .WebApi Project.
/// <summary> /// Web API layer of the application. /// </summary> [DependsOn(typeof(AbpWebApiModule), typeof(OnlineSystemsApplicationModule), typeof(AbpWebApiODataModule))] public class OnlineSystemsWebApiModule : AbpModule { public override void PreInitialize() { var builder = Configuration.Modules.AbpWebApiOData().ODataModelBuilder; //Configure your entities here... builder.EntitySet<PersonofConcern>("PersonofConcern"); } public class PersonofConcernController : AbpODataEntityController<PersonofConcern> { public PersonofConcernController(IRepository<PersonofConcern> repository) :base (repository) { } }
-
0
Hi,
Does audit fields return when you use another entity which has less fields ? I think this might be related to oData but I'm not very sure since I don't have much information on this area.
There might be limitations of oData about returning column count.
Thanks.
-
0
Even when I call: <a class="postlink" href="http://localhost:6240/odata/$metadata#Pocs">http://localhost:6240/odata/$metadata#Pocs</a>
I don't get all fields!
I am not sure if oData is working fine in Abp.
What's the workaround? Any idea?
Thanks
-
0
Hi,
I am not sure if oData is working fine in Abp.
Actually, we didn't get similar issue before but I'm not sure actually :). If you have time, can you try with pure oData ?
-
0
So I don't use the OData modude by ABP?
Where shall I configure oData? In the WebApi project? Using PostInitialize?
-
0
Hi @drcgreece,
You can use OData with ABP, we have many users using it already. Your configuration also seems correct.
I just couldn't understand the reason why not all fields are returing from your query. That's why I asked to do it without ABP if you have time.
If you don't have time for this, can you share one of your entities you have tried with ABP and also please send list of not returing fields. I will try to reproduce same case with ABP.
If possible, sending whole project might be easier to test for me :).
Thanks.
-
0
Thanks Ismail. I can do it myself, I just wanted to know where to put the configuration. Can you let me know?
Also, I can send you a sample project like usual to check it out.
-
0
Hi,
When I checked, your configuration seems correct actually. I think it is better you to send project to me :), I will try to find the problem.
In the mean time, you can try it with pure oData if you have time.
Thanks.
-
0
Hi @drcgreece,
I have checked your project and probably the not returning fields are related to their property definitions in your class. For example when FirstName field is defined like this, it is not returned to client
public string FirstName { get; internal set; }
But if we change it like this, it is returned.
public string FirstName { get; set; }
You can try this and configure your classes accordingly.
Thanks.