Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Generics, business objects, business rules [solution]
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01314400
Message ID:
01315495
Views:
23
Patrick,

>[solution]
>After looking at patterns in mmBusinessObjectGeneric I realized that the variable, the generic to follow was , duh.
>
>
>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.

You've got it! The "new()" constraint says the method is allowed to create instances of the specified entity type.

Best Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Previous
Reply
Map
View

Click here to load this message in the networking platform