Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Use business objects from within a business rule
Message
 
À
28/02/2005 10:49:39
Jason Mesches
Ocean Systems Engineering Corporation
Carlsbad, Californie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
00991068
Message ID:
00991228
Vues:
17
Thanks, Jason. I guess (no, I know) I'm a bit dense here...

If I use YourBusinessRule.HostObject, then I'm refering back to the biz object that called the biz rule in the first place - is that correct? If so, then that would not work as I need to reference a different business object.

On the other hand, if I create business objects from within the business rule object, then I have some redundancy going on... I have a business object created in the usual way, and then I have to create another one embedded in the business rule that does the same thing. In that case, I've just lost all the advantages of an n-tier, OOP design. Of course, the most likely scenario is I just simply don't properly understand the answer :)

What I need is something like an invoice object which as a whole represents the invoice header AND invoice items, for example. The way I have to relate the parent and child objects now, well, I'm doing it in the web page form code. Seems like I should be able to define one invoice object that encapsulates the whole "invoice".

Regards,
Carl.


>Hello Carl,
>
>You can use YourBusinessRule.HostObject property. This stores a reference to the object responsible for creating YourBusinessRule object. One thing to keep in mind, though, is that this reference is stored as ImmBusinessRuleHost type. IOW, you'll have to cast it to your business object for access to the custom methods you're probably looking to implement.
>
>For references to other/multiple objects, you're best off creating them from within the business rule object. We've also used mmBusinessProcess to coordinate multiple business objects' methods.
>
>Hope that helps,
>---J
>
>>How would I call one or more business objects from within a business rule class? There are some cases where data validation is based on a number of conditions that can only be determined by using other business objects accessing different database tables. For instance, I want to do something like this within business rule:
>>
>>
>>Public Function ValidateCreditRating(ByVal creditRating As String, ByVal creditCode As String, ByVal customerID As Integer) As String
>>        Dim message As String = Nothing
>>        ' check rating
>>        If creditCode = "Z" Then
>>            Dim ratingGood As Boolean
>>            ratingGood = Me.oCreditCheck.CheckRating(creditRating, customerID)
>>            If ratingGood = False Then
>>                message = "Credit rating too low."
>>                Me.AddErrorProviderBrokenRule("CreditRating", message)
>>            End If
>>        End If
>>        Return message
>>    End Function
>>
>>
>>A bit of a cheesy example, but hopefully it gets the idea across. Unfortunately, I get an object not referenced error when I try to do the something like the above.
>>
>>Any ideas?
>>
>>Regards,
>>Carl.
Carl Olson, Jr.
CEO, Founder
Cerelogic, Inc.

www.cerelogic.com

"Applying rocket science to business."
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform