Good day. Struggling a bit to get this REALM to sync. I’m seeing some erronious, what feels to me, errors and maybe my backed instance has an issue, but lets see what the smart people can see.
I have a pretty basic collection for sales in C# with two nested arrays of objects.
[Serialized]
public class Sale : RealmObject
{
private DateTime _businessDay;
private DateTime _startTime;
private DateTime _endTime;
public Sale()
{
_id = ObjectId.GenerateNewId();
Payment = new List<Tender>().ToArray();
SalesItems = new List<LineItem>().ToArray();
}
public enum SaleIndexes
{
SALE_REF_ID_INDEX,
BUSINESS_DATE_INDEX,
LOCATION_REF_ID_INDEX,
WHO_START_INDEX,
WHO_END_INDEX,
SALE_TYPE_INDEX,
SERVICE_AREA_INDEX,
START_TIME_INDEX,
END_TIME_INDEX,
GUEST_COUNT_INDEX,
SALE_TIME_BLOCK_INDEX,
NET_TOTAL_INDEX,
GROSS_TOTAL_INDEX,
TENDER_TYPE_INDEX,
TENDER_INDEX,
TIP_INDEX,
GRATUITY_INDEX,
TAX_INDEX,
ITEMS_INDEX
}
[BsonId]
[PrimaryKey]
public ObjectId _id { get; set; }
[BsonElement("sale_ref_id")]
public int SaleRefId { get; set; }
[BsonElement("business_day")]
public DateTime BusinessDay
{
get { return DateTime.SpecifyKind(_businessDay, DateTimeKind.Utc); }
set { _businessDay = (DateTime)value; }
}
[BsonElement("location_ref_id")]
public ObjectId LocationRefId;
[BsonElement("who_start")]
public int? WhoStart { get; set; }
[BsonElement("who_end")]
public int? WhoEnd { get; set; }
[BsonElement("sale_type")]
public string? SaleType { get; set; }
[BsonElement("service_area")]
public int? ServiceArea { get; set; }
[BsonElement("start_time")]
public DateTime? StartTime
{
get { return DateTime.SpecifyKind(_startTime, DateTimeKind.Utc); }
set { _startTime = (DateTime)value; }
}
[BsonElement("end_time")]
public DateTime? EndTime
{
get { return DateTime.SpecifyKind(_endTime,DateTimeKind.Utc); }
set { _endTime = (DateTime)value; }
}
[BsonElement("guest_count")]
public double GuestCount { get; set; }
[BsonElement("time_block")]
public double TimeBlock { get; set; }
[BsonElement("net_total")]
public double NetTotal { get; set; }
[BsonElement("gross_total")]
public double GrossTotal { get; set; }
[BsonElement("payment")]
public Tender[] Payment { get; set; }
[BsonElement("tax")]
public double Tax { get; set; }
[BsonElement("gratutity")]
public double Gratuity { get; set; }
[BsonElement("sales_items")]
public LineItem[] SalesItems { get; set; }
}
The error in the subject is thrown when I try to initialize the REALM and the sync should happen, but we never get there.
The Tender model is as such. Nothing crazy?
[Serializable]
public class Tender : EmbeddedObject
{
public Tender()
{
this._id = ObjectId.GenerateNewId();
}
[BsonId]
public ObjectId _id { get; set; }
[BsonElement("sale_ref_id")]
public int SaleRefId { get; set; }
[BsonElement("tender_type")]
public string TenderType { get; set; } = "";
[BsonElement("value")]
public double Value { get; set; }
[BsonElement("tip")]
public double Tip { get; set; }
}
}
There’s a similar model for the LineItem[]
SalesItems property but that’s not complaining…yet.
Is this error familiar to some of the Mongo Champs out there?
Thanks in advance.
CPT