Resolve references with the .NET Client

I have…

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [ ] Bug report
  • [ ] Performance issue
  • [x ] Documentation issue or request

Environment

  • [x ] Self hosted with docker
  • [ ] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: 5.3

Browser:

  • [x ] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Is there any option to resolve references to other content items when using the .NET client library in the same call? I see that there is the X-Resolve-Urls for assets, is there anything similar to content items?

Just use GraphQL I would say…

Hey

Sorry to bring this thread back alive but I’m also having some issues and since I don’t know GraphQL I first want inquire about this.

It is not possible with the .NET Client to know what kind of type the reference is?
I just receive a list of the referenced guids, but not the type?

The only way to solve this is to

  1. Query every possible reference with the id’s
  2. Use GraphQL

Hi,
I know it does not look like this, but the following method resolves contents by ids across all schemas: https://github.com/Squidex/squidex-samples/blob/master/csharp/Squidex.ClientLibrary/Squidex.ClientLibrary/ContentsClient.cs#L96

You can just take 100 ids or so from 50 schemas and put them all in.

Thanks for the tip!

I’ve actually used it already, but just for one schema.
I assume the TData needs to have all the properties of all different schema’s i’m trying to resolve?

And not 1:1 from TData to Schema?

Or a dynamic structure like JObject or Dictionary or so.

Hey Sebastian

Could you give me an example with the JObject or Dictionary?

I tried using the JObject approach (Code below) but my ‘data field’ ends up being empty.

// JObjectContent
public class JObjectContent : Content<JObject> { }

// Client
clientManager.CreateContentsClient<JObjectContent, JObject>("schema");

// Request & parsing
 var sectionObjects = await SectionClient.GetAsync(ids);

foreach (var section in sectionObjects.Items) {
   var sectionVM = section.SchemaName switch {
       "cardsection" => Mapper.Map<CardSectionVM>(section.Data.ToObject<CardSectionData>()),
       "imagesection" => Mapper.Map<ImageSectionVM>(section.Data.ToObject<ImageSectionData>()),
       _ => Mapper.Map<SectionVM>(section.Data.ToObject<BaseSectionData>())
   };
   // ...
}

The code “works” as in it doesn’t throw an error. But my section.Data fields are all empty.

The client library includes DynamicContent class for that. Sorry, I have forgotten it.