public CategoryMedicineObject(CategoryMedicineDbRecord dbRecord) : base(dbRecord)
 {
     DbRecord.Category = DbRecord.Category ?? new CategoryDbRecord();
     DbRecord.Medicine = DbRecord.Medicine ?? new MedicineDbRecord();
     Category          = new CategoryObject(DbRecord.Category);
     Medicine          = new MedicineObject(DbRecord.Medicine);
 }
        public static CategoryMedicineObject Create(CategoryObject category, MedicineObject medicine,
                                                    DateTime?validFrom = null, DateTime?validTo = null)
        {
            var o = new CategoryMedicineDbRecord
            {
                Category  = category?.DbRecord ?? new CategoryDbRecord(),
                Medicine  = medicine?.DbRecord ?? new MedicineDbRecord(),
                ValidFrom = validFrom ?? DateTime.MinValue,
                ValidTo   = validTo ?? DateTime.MaxValue
            };

            o.CategoryID = o.Category.ID;
            o.MedicineID = o.Medicine.ID;
            return(new CategoryMedicineObject(o));
        }