Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do you specfiy Business Entity to use within the BO?
Message
De
07/04/2008 15:19:35
 
 
À
07/04/2008 11:03:16
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01308629
Message ID:
01308824
Vues:
14
It sure seems like the MM framework would have a naitive way to deal with this.

Here is what the MM Dev Guide says:
----------------------------------------------------------------
This architecture also allows the business object to return different "shapes" of entity objects. For example, you can return an entity object that has all properties corresponding to columns in a data table when you want to edit, or you can return an entity object that only has a primary key and description when binding to read-only lists.
----------------------------------------------------------------

Now then..

I don't understand how your suggestion will handle this matter... In looking at the BO class code, the Customer class seems to define its Entity object specifically based on the default CustomerEntity class that was defined in my Customer.Partial.cs file by the BusinessLayerGeneterator tool (i.e. the default Entity class). So, how would you use the CreateEntityObject() method to create a different Entity that the very type of entity on which the Entity class is being defined as?

Also, all the custom GetEntity() and GetEntityList() methods that you define in the Customer.Partial.cs are also of the type CustomerEntity. So there is another area where you would have to deal with altering type of entity you want these methods to generate and return.


Obviously, there are a few things I don't understand yet. Any insight you can provide is greatly appreciated.




>Matt,
>
>Override the factory CreateEntityObject()and put a decision in there. You could set a property to drive the decision as one method.
>
>Tim
>
>>I read in the Dev Guide about "Working with Different Shaped Entities", and I think I need to do this in a few cases, so... How do you tell the Business Object *WHICH* Entity to use when it is instantiated? I see how to create additional Entity "shapes" using the Business Layer Generator, but how do I create an instance of a my Customer BO on one form that is based on the default Entitiy, but also have a Customer BO on another form that is based off a different Entity definition?
>>
>>In looking at my Customer.cs code file for the Customer BO, it seems to pretty much be hard-coded to use the default CustomerEntity entity class.
>>
>>Also, can you switch between Entities within one instance of a BO object?
>>
>>Code below is from Customer.cs:
>>
>>
>> public partial class Customer : ABusinessObject
>> {
>>
>> #region Association Properties
>>
>> ///
>> /// Business Entity object
>> ///

>> public override CustomerEntity Entity
>> {
>> get
>> {
>> if (this._entity == null)
>> {
>> this._entity = this.CreateEntityObject();
>> }
>> this._entity.SetDataRow(this.DataRow);
>> return this._entity;
>> }
>> set
>> {
>> this._entity = value;
>> if (this._entity != null)
>> this.DataRow = this._entity.GetDataRow();
>> else
>> this.DataRow = null;
>> }
>> }
>> private CustomerEntity _entity;
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform