JSON as a list-collection from an API call

Hi,

New into Radzen: very nice!

I have a MSSQL database with foreign keys to other tables and would like to get the complete collection returnd from an API call

In the db-context the collections should be there

    builder.Entity<Cloud13.Models.CloudData.Car>()
          .HasOne(i => i.Parts)
          .WithMany(i => i.Cars)
          .HasForeignKey(i => i.PartId)
          .HasPrincipalKey(i => i.Id);

The logic of the database is like this

car has a collection of parts

I would like to get a json from the api like:

{
  "CarId": 1,
  "CarName": "mycar",
  "CarCode": "cxx1xx",
  "parts": [
    {
      "partId": 1,
      "partName": "wheel"
    },
    {
      "partId": 1,
      "partName": "wheel"
    },
    {
      "partId": 1,
      "partName": "wheel"
    }
  ]
}

How can i achieve this result?

Thanks!

Mike

Hi Mike,

You can get result like this using $expand. For example on Page Load event with our Sample MSSQL data source:

In your case $expand parameter should be Parts.

Best Regards,
Vladimir

Awesome !!!
Learning a lot here: got it to work and exactly what i wanted.

Small question: How can i 'push/post' new data with the api/json tool Postman?
Including the collection (cars->parts)

If i need to do it manually: How do i set this up?

BTW: when adding a MSSQL database it works for me only when the first letter of the name is a capital. Otherwise the resulting model has issues with the namespace.

Hi Mike,

Posting sub properties/collections (cars -> parts) is not supported. If the app is running in Radzen you can POST data with Postman like this:

Can you provide more info about the namespace error? We will include a fix in our next release!

Best Regards,
Vladimir

Thanks for the feedback. The app is a small Xamarin.Forms app which i want to use to update the db-info. But i like to test/try the get/patch api calls with Postman.

So sub-properties/collections are not supported. Maybe i can go for another approach? Feed it in a different way? What could be my options to still update the whole tree of car->parts.
Only 1 car and its parts and its sub-parts is what needs to get synced back and forth (get/patch).

The namespace error: Blazor --> try to add a new MSSQL database and use a lowercase value for the Name field

image