Paymentsense / Dapper.SimpleLoad

Dapper.SimpleLoad
MIT License
13 stars 4 forks source link

Don't require all foreign key back references to be satisifed. #12

Open bartread opened 8 years ago

bartread commented 8 years ago

E.g., this can cause a problem:

    [Table("[cust].[MERCHANT_LEGAL_INFO_TRN]")]
    public class MerchantLegalInfoDto : BaseGoofyAuditableTrn
    {
        [PrimaryKey]
        public int? MerchantLegalInfoKey { get; set; }

        [ForeignKeyReference(typeof(MerchantMasterDto))]
        public Guid? MerchantGuid { get; set; }

        [ManyToOne]
        [ForeignKeyReference(typeof(FullAddressDto))]
        [Column("AddressGuid")]
        public FullAddressDto Address { get; set; }

        [ManyToOne]
        [ForeignKeyReference(typeof(ContactMasterDto))]
        [Column("ContactGuid")]
        public ContactMasterDto Contact { get; set; }

        public int BusinessLegalTypeKey { get; set; }

        public string RegisteredName { get; set; }

        [DateIsNullOrInThePast]
        public DateTime? CompanyStartDate { get; set; }

        [DateIsNullOrInThePast]
        public DateTime? CompanyRegistrationDate { get; set; }

        public string CompanyRegistrationNumber { get; set; }

        public string RegisteredCharityNumber { get; set; }

        public string VATNumber { get; set; }

        public bool IsCurrent { get; set; }
    }

Specifically, if you want to use this DAO in a query that doesn't involve a MerchantMasterDto it will throw an error because it can't find a JOIN target for the MerchantGuid column/property.

Ideally it would either ignore this or, at worst, issue a warning. The latter may not even be necessary. You really want to be able to use DAOs in queries as flexibly as possible.