Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Should Entities refer to fields from related tables?
Message
From
28/05/2010 17:08:45
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/05/2010 13:34:29
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01466424
Message ID:
01466447
Views:
36
>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform