using System; using InABox.Core; namespace Comal.Classes { public interface ICustomerProduct { CustomerLink Customer { get; set; } ProductLink Product { get; set; } ProductCharge Charge { get; set; } } [UserTracking(typeof(Product))] public class CustomerProduct : Entity, IPersistent, IRemotable, ICustomerProduct, IManyToMany, IManyToMany, ILicense, IExportable, IImportable { [EntityRelationship(DeleteAction.Cascade)] [EditorSequence(1)] public CustomerLink Customer { get; set; } [EntityRelationship(DeleteAction.Cascade)] [EditorSequence(2)] public ProductLink Product { get; set; } [ProductChargeEditor] [EditorSequence(3)] public ProductCharge Charge { get; set; } } public class CustomerProductUnionGenerator : AutoEntityUnionGenerator { protected override void Configure() { AddTable(); AddTable() .AddConstant(x => x.Customer.ID, Guid.Empty) .AddConstant(x=>x.Product.ID, new Column(x=>x.ID)); } public override bool Distinct => false; public override Column[] IDColumns => new Column[] { new Column(x => x.Customer.ID), new Column(x => x.Product.ID) }; } [AutoEntity(typeof(CustomerProductUnionGenerator))] public class CustomerProductSummary : Entity, IRemotable, IPersistent, ICustomerProduct, ILicense { public CustomerLink Customer { get; set; } public ProductLink Product { get; set; } public ProductCharge Charge { get; set; } } }