References and many-to-many relationships

I have created 3 schema classes: Models, Grades, and Accessories

In the schema, Grades have a reference field to Models

Using C# and the squidex nuget library, what do I define the reference property as?

public sealed class ModelData
{

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

}

public sealed class GradeData
{

[JsonConverter(typeof(InvariantConverter))]
public **xxxx** ModelID { get; set; }

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

}

What is the type for xxxx above?

Also, I want to create a many-to-many relationship between Grades and Accessories, so I created an additional Schema table called GradeAccessories with a reference to Grades and a reference to Accessories. Is there any way to represent this relationship automatically in the model and populate the referential data automatically when I call GetAsync on either one of the Grade or Accessories classes?

If you use the REST APi, you will only receive IDs. Either List<string>, string[], List<Guid>, Guid[] or other collections such as HashSet will work.

If you use GraphQL you can reference the accessories directly.

Please not that ALL references are usually M:N, so you do not need the GradeAccessories schema. Just add a reference field to your Grade schema to the accessories.

Hi Sebastian,

Thanks for your help. Reference Ids coming through.

I’ve never used GraphQL before. Time to do some reading…