-
I try to create a function in Edm modelbuilder.EntitySet<CategoryViewModel>("PCategories");
var category = builder.StructuralTypes.FirstOrDefault(t => t.ClrType == typeof(CategoryViewModel));
category.AddProperty(typeof(CategoryViewModel).GetProperty(nameof(CategoryViewModel.NiceUrl))); // Add readonly property
builder.EntityType<CategoryViewModel>()
.Collection
.Function("GetChildren")
.ReturnsCollectionFromEntitySet<CategoryViewModel>("PCategories")
.Parameter<Guid>("ParentId"); Controller//[EnableQuery(PageSize = 10, AllowedQueryOptions = AllowedQueryOptions.All)]
//[Route("odata_products/PCategories({parentId})/GetChildren")]
[HttpGet]
public async Task<IActionResult> GetChildren(ODataActionParameters parameters /*Guid parentId*/)
{
Guid parentId = (Guid)parameters["parentId"];
var categories = await _categoryService.QueryEntitiesAsync();
return Ok(categories);
} |
Beta Was this translation helpful? Give feedback.
Answered by
datnt97
Aug 30, 2022
Replies: 1 comment
-
I figured out my problem. The method |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
datnt97
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured out my problem. The method
QueryEntitiesAsync
return incorrectly type.But
$odata
still doesn't display anything