在 NoSql 中存储扩展实体

Store expanded entity in NoSql

在adrian hall 的书中,有一个用子对象获取对象的例子。 在这种情况下,它看起来像这样:

public class JobDTO : EntityData
{
    public string AgentId { get; set; }
    public DateTimeOffset? StartTime { get; set; }
    public DateTimeOffset? EndTime { get; set; }
    public string Status { get; set; }
    public string Description { get; set; }  

    public virtual CustomerDTO Customer { get; set; }
    public virtual List<EquipmentDTO> Equipments { get; set; }
}

可以看到,有一个客户,数据复杂,设备多

在客户端,我们可以在nosql离线存储中存储这样复杂的数据吗?

是的,为什么不呢。 只需按照此文档使用离线商店 https://docs.microsoft.com/en-us/azure/app-service-mobile/app-service-mobile-xamarin-forms-get-started-offline-data

On the client side, can we store complex data like this in the nosql offline store?

根据您的描述,我查了 The Domain Manager adrian hall 的书。另外,我测试了类似的代码,复杂的数据可以存储在SQLite离线存储中,如下:

对于offline Sync,将本地Job table推送到远程时,服务器端需要忽略关系CustomerEquipments,如下所示:

// For incoming requests, ignore the relationships
cfg.CreateMap<JobDTO, Job>()                                            
    .ForMember(job => job.Customer, map => map.Ignore())
    .ForMember(job => job.Equipments, map => map.Ignore());

作为同步作业的 Existing Table Relationships with the MappedEntityDomainManager 状态 table:

Customer and Equipment data all comes down as one record. This has a side effect of ensuring that the Customer and Equipment data is read-only. You can only update the information in the Job table.

此外,正如 Adrian Hall 提到的,他更喜欢单独处理 table 并在移动客户端上手动处理关系管理。这会在移动客户端上产生更多代码,但通过避免大部分关系的复杂性使服务器变得更加简单。