We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

SfDataManager ODataV4Adaptor Inheritence

Dear support,

How to specify a cast to  derived entity dynamically (without setting it at the Url parameter) ?

Currently:

https://localhost:7003/v1/TransCategoryBases(10d2ceb1-f292-49bc-9230-1de352c656b4)

To:

https://localhost:7003/v1/TransCategoryBases(10d2ceb1-f292-49bc-9230-1de352c656b4)/AMI.FinancialTransCategoryModel


Simple Odata Example:

var flights = await client
    .For<Person>()
    .Key("russellwhyte")
    .NavigateTo(x => x.Trips)
    .Key(1003)
    .NavigateTo(x => x.PlanItems)
    .As<Flight>()
    .FindEntriesAsync();

Advanced OData Tutorial with Simple.OData.Client · OData - the Best Way to REST



5 Replies

KG Keerthana Ganesan Syncfusion Team November 15, 2022 10:51 PM

Hi Vincent,

Greetings from Syncfusion support.

We analyzed your scenario, and we suggest you set the BatchUrl and Url properties of SFDataManager to achieve your requirement. Please refer to the below code snippet.

<SfGrid @ref="Grid1" TValue="Vehicle" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Toolbar="@(new List<string>() { "Cancel", "Update" })">

    <SfDataManager @ref="dm" Url="/Vehicles?$expand=VehicleMake" BatchUrl="/Vehicles" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager>

    <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" Mode="EditMode.Batch"></GridEditSettings>

    <GridColumns>

        <GridColumn Field="@nameof(Vehicle.VehicleId)" IsPrimaryKey="true" Visible="false"></GridColumn>

        <GridColumn Field="@nameof(Vehicle.RegistrationNumber)"></GridColumn>

        <GridColumn Field="VehicleMake.VehicleMakeText"></GridColumn>

    </GridColumns>

</SfGrid>


Kindly get back to us if you have any further queries.



VB Vincent Bray November 16, 2022 03:22 AM

Dear support,

This workaround is not working, as for expemple, I need to expand a property on the derived object when initializing the grid.

I clearly need a "Cast" functionality so that the data manager only add the cast url block at the end of the default query behaviour.


get:

Actually: https://localhost:7003/v1/TransCategoryBases

Expectedhttps://localhost:7003/v1/TransCategoryBases/AMI.FinancialTransCategoryModel


patch:

Actually: https://localhost:7003/v1/TransCategoryBases (10d2ceb1-f292-49bc-9230-1de352c656b4)

Expected https://localhost:7003/v1/TransCategoryBases(10d2ceb1-f292-49bc-9230-1de352c656b4) /AMI.FinancialTransCategoryModel

and not https://localhost:7003/v1/TransCategoryBases/AMI.FinancialTransCategoryModel (10d2ceb1-f292-49bc-9230-1de352c656b4)

if I cast at the url level like below

<SfDataManager Url="@($"{xxxx}/TransSubCategoryBases/AMI.FinanceTransCategoryModel")" .../>




KG Keerthana Ganesan Syncfusion Team December 5, 2022 05:07 AM

We have analyzed your query and we suggest you add parameters dynamically by using Add params method. We have discussed this topic in detail in our UG documentation. Kindly refer to the attached document link for your reference.

Reference link: https://blazor.syncfusion.com/documentation/datagrid/data-binding#sending-additional-parameters-to-the-server



VB Vincent Bray December 5, 2022 05:24 AM



VB Vincent Bray December 5, 2022 05:26 AM

Please close the ticket


Loader.
Live Chat Icon For mobile
Up arrow icon