Multiple Self Reference does not work with Locode

It doesn’t show the connections correctly.

public class Address
{
    [AutoIncrement]
    [PrimaryKey]
    public long Id { get; set; }
    public string? AddressText { get; set; }
}
public class QueryAddresses : QueryDb<Address>
{
    public long[] Ids { get; set; }
}

public class CreateAddress
: ICreateDb<Address>, IReturn<IdResponse>
{
    public string? AddressText { get; set; }
}

public class UpdateAddress
    : IPatchDb<Address>, IReturn<IdResponse>
{
    public int Id { get; set; }
    public string? AddressText { get; set; }
}

It doesn’t work in my application either, but I included it in an example program in the Booking class:

public class Booking : AuditBase
{
    [AutoIncrement]
    public int Id { get; set; }
    public string Name { get; set; } = default!;
    public RoomType RoomType { get; set; }
    public int RoomNumber { get; set; }
    [IntlDateTime(DateStyle.Long)]
    public DateTime BookingStartDate { get; set; }
    [IntlRelativeTime]
    public DateTime? BookingEndDate { get; set; }
    [IntlNumber(Currency = NumberCurrency.USD)]
    public decimal Cost { get; set; }

    [Ref(Model = nameof(Coupon), RefId = nameof(Coupon.Id), RefLabel = nameof(Coupon.Description))]
    [References(typeof(Coupon))]
    public string? CouponId { get; set; }

    [Reference]
    public Coupon Discount { get; set; }
    public string? Notes { get; set; }
    public bool? Cancelled { get; set; }
    [References(typeof(Address))]
    public long? PermanentAddressId { get; set; }
    [Reference]
    public Address? PermanentAddress { get; set; }

    [References(typeof(Address))]
    public long? PostalAddressId { get; set; }
    [Reference]
    public Address? PostalAddress { get; set; }
}

Two different records but showing the same name.

What am I messing up?

It would be ambiguous if you’re trying to reference the same external table. You can try using the [RefId] to explicitly define the relationship, e.g:

[References(typeof(Address))]
public long? PermanentAddressId { get; set; }

[Ref(Model = nameof(Address), SelfId = nameof(PermanentAddressId), RefId = nameof(Address.Id))]
[Reference]
public Address? PermanentAddress { get; set; }

Yes, I already tried it with RefId, but not with SelfId. Now I tried, but the result is similar.
It is interesting that the Grid shows the classes well, but not the Id.


But the update form is unchanged:

I upload the test project: GitHub - Zantuum-Kft/MyApp1

I can see the Id located on the top right of each control?

Yes, you can see it in the picture, the id changed, but the displayed text is always same.

And it similar on the grid:

Can you try setting the RefLabel as well to the text you want displayed, e.g:

[Ref(..., RefLabel = nameof(Address.City))]

Yes, I already tried this in my own application, but now I put it in the example code, but it doesn’t work here either!
MyApp1/MyApp.ServiceModel/Bookings.cs at master · Zantuum-Kft/MyApp1

This wasn’t supported before, but should now work with the latest v8.4.1+ that’s now available in the Pre Release packages.

Note: you shouldn’t need any [Ref] attributes for your Address properties, if you did want to add them they should be on the field in the form, i.e. PermanentAddressId instead of PermanentAddress which is a reference property for returning extra data, but is not included in the form fields.

Also your Address fields should only be on the Data Model since it’s used to return referential data, it shouldn’t be on the other Create/Update Request DTOs which are your API to update the data model which isn’t sent or updates the referential data.

public class CreateBooking / UpdateBooking
{
//...
    public long? PermanentAddressId { get; set; }
    // public Address? PermanentAddress { get; set; }
    public long? PostalAddressId { get; set; }
    // public Address? PostalAddress { get; set; }
}