public class ABusinessRule : mmBusinessRule { ... #region validate specific data type methods // fake code, doesn't work public string ValidateDuplicateOrder<BusinessType>( BusinessType oBusiness, string order, string sku) where BusinessType : ABusinessObject // needs a type ... ABusinessObject<EntityType> ... OrderType1 ... { // make data access call common to all business object types // deriving from ABusinessObject int recsFound = oBusiness.GetDuplicateOrder(order, sku); if (recsFound > 0) AddErrorProviderWarning(...) }[solution]
public class ABusinessRule : mmBusinessRule { ... #region validate specific data type methods public string ValidateDuplicateOrder<EntityType>( ABusiness<EntityType> oBusiness, string order, string sku) where EntityType : mmBusinessEntity, new() // the right type // but, what does "new()" do, or mean? { int recsFound = oBusiness.GetDuplicateOrder(order, sku); if (recsFound > 0) AddErrorProviderWarning(...) }So, in a Order Type Business Rule:
public partial class OrderType1Rules : ABusinessRule { ... public string ValidateDuplicateOrderType1( string order, string sku) { // note the casting of the business rule's HostObject to a compatible type return ValidateDuplicateOrder((OrderType1)this.HostObject, order, sku); }If there's a better pattern, please let me know.