Table with relationship to itself

I’m submitting a…

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

Current behavior

I have defined a schema called Accessories. This schema then has a relationship field called Subcomponents, which is a reference back to the Accessories schema. Everything works fine as far as setting this up and setting up relationships through the Squidex portal, however when fetching the accessories items through the Squidex ClientLibrary with C#, The subcomponents property is always empty.

Expected behavior

The subcomponents property should be filled with a List of ids of the related items.

Minimal reproduction of the problem

Have a table with a relationship to itself and see if you can get the related items to load using the ClientLibrary

Environment

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

Version: ClientLibrary 2.8.0

Browser:

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

Others:

Can you share some code? Are the references entities published? Do you get back null or an empty list?

It is an empty list. I’ll try and supply some code.

[KeepCasing]
public sealed class AccessoryData
{
    [JsonConverter(typeof(InvariantConverter))]
    public string PartNumber { get; set; }

    [JsonConverter(typeof(InvariantConverter))]
    public string Title { get; set; }

    [JsonConverter(typeof(InvariantConverter))]
    public List<string> Subcomponents { get; set; }
}

public sealed class SquidexAccessory : SquidexEntityBase<AccessoryData>
{
}

private async Task<bool> LoadData()
{
	var accessoryClient = ClientManager.GetClient<SquidexAccessory, AccessoryData>("accessories");
	var accessories = await accessoryClient.GetAsync();
	foreach (var accessory in accessories.Items)
	{
		if (accessory.Data.Subcomponents != null && accessory.Data.Subcomponents.Count > 0)                    
			var intCount = accessory.Data.Subcomponents.Count; //This is never more than 0
	}
}

Sebastian, I think you are right, the references are unpublished because these were created manually where the rest of the data was created with an import process. I will publish now and let you know if any further problems. Sorry if I wasted your time.

No problem, you are welcome :slight_smile: