Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Should Entities refer to fields from related tables?
Message
De
28/05/2010 17:08:45
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
28/05/2010 13:34:29
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01466424
Message ID:
01466447
Vues:
37
>Hi,
>
>I have a Clients table and a Policies table. A client can have one or many policies. When displaying a single Policy I want to display some of the client details like Name and Number. Should I set Client as a child business object of Policy, or should I include the related fields in the Policy entity?

If you have required relations set in database then when you use the EF designer it adds the navigational properties and you would simpky say for example:
Policy oPolicy = db.Policies.Single( p => p.Id == policyId );
Client c = oPolicy.Client;
or the other way:
Client c = db.Clients.Single( c =>c.Id clientId);
foreach(var policy in c.Policies) {//...}
Update: Discard. I din't notice it was mm section.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform