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; }
}
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.
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; }
}