Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best Design For This
Message
De
30/03/2009 13:11:21
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01390847
Message ID:
01392154
Vues:
60
>I have a customer record, which has one or more account records. Each account can have one or more invoice headers, each with one or more invoice detail records. I wrote a class for each.
>
>When I create an instance of a customer class and call LoadCustomer, should that process also create a collection of accounts on the customer class. Then, should each account create a collection of invoice headers, which in turn would create a collection of invoice details?

Kevin,
Didn't read all the messages so I don't know if I am repeating. Check entity framework and Linq. One easy way to model what you need would be by creating an SQL database (because I think you know how to express it with tables and relations better than you know how to express with objects). After creating your SQL db, generate an ADO.Net entity model from that database. EF does a great job there and (getting Northwind as a sample) you end up with objects like Customers, Orders, OrderDetails. Then in code all you need is some cool Linq. i.e:
NorthwindEntities nw = new NorthwindEntities();
var customer = nw.Customers.Single( c => c.CustomerID == "ALFKI" );

string comp = customer.CompanyName;
foreach( var od in customer.Orders.FirstOrDefault().OrderDetails )
{
// do something
}
customer (string comp) and OrderDetails is not queried until you ask for it (foreach).
var usaCustomers = from c in nw.Customers where c.Country == "USA" select c;

foreach(Customers c in usaCustomers)
{
if ( c.CompanyName.StartsWith( "L" ) )
   { Console.WriteLine( c.Orders.FirstOrDefault().Employee.FirstName ); }
}
You concentrate on object model with this approach (IMHO).
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
Répondre
Fil
Voir

Click here to load this message in the networking platform