- ABP Framework version: v4.4.0
- UI type: Blazor
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): no
Hello,
I am trying to implement Entity extention for abapusers as per: https://docs.abp.io/en/abp/4.4/Module-Entity-Extensions#module-entity-extensions
In Version 4.4.0, what would be the best approach to extract data from database and generate a list in json format to be used by the abp user form? I am trying to create a lookup field to pick customer ID.
An example implementation that returns a fixed list of departments (in real life, you get the list from a data source):
[Route("api/departments")]
public class DepartmentController : AbpController
{
[HttpGet]
public async Task<ListResultDto<DepartmentDto>> GetAsync()
{
return new ListResultDto<DepartmentDto>(
new[]
{
new DepartmentDto
{
Id = Guid.Parse("6267f0df-870f-4173-be44-d74b4b56d2bd"),
Name = "Human Resources"
},
new DepartmentDto
{
Id = Guid.Parse("21c7b61f-330c-489e-8b8c-80e0a78a5cc5"),
Name = "Production"
}
}
);
}
}
The code above is hardcoded list of Departments, how can I get the same list of departments from a database?
Thanks,
Nestor
2 Answer(s)
-
0
Hi @nparejod,
You can inject
IRepository<Department, Guid>
and use it to perform query on database.It would be better to create a domain service for this lookup list operation.
-
0
This question has been automatically marked as stale because it has not had recent activity.