Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One to One Relationship
Message
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01146234
Message ID:
01146246
Vues:
13
Fred,

>I have a One to One relationship.
>
>User
>-----
>ID
>ContactID
>
>Contact
>--------
>ID
>FirstName
>LAstName
>Address
>
>I have a contact table for different reasons(clients,Employees,suppliers etc) so the contact table will have a one-one relationship with many tables.
>
>How should the user Business Object be?
>in User Business Object have an Entity of type contact ? there is no parent or child relationship so how would on add new row for user also add new roe for contact ?

Well, if you're comfortable with stored procedures, you can allow your business objects to provide an unnormalized view of data. You can create a stored procedure that retreives all the columns from User and Contact and generate an entity object from this SELECT stored procedure. Then create insert, update, and delete stored procedures that update the data accordingly. This would require you to create a custom data access class for your User business object which is discussed in the MM .NET Dev Guide topic "Creating Custom Data Access Classes".

The alternative is to create separate User and Contact business objects. You could then reference the Contact business object from within the user business object. You could create a property like this on the User object:
property Contact oContact
{
   get
   {
      if (_contact == null)
      {
         _contact = new Contact();
         this.RegisterBizObj(_contact};
      }
      return _contact;
   }
   set { _contact = value; }
}
private Contact _contact;
Notice the oContact property contains a reference to the Contact business object. The first time the property is referenced an instance of Contact is created and registered with the User business object. This allows all the automatic "mojo" in MM .NET to kick in (if so desired).

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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform