Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Design Flexibility
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00929944
Message ID:
00930487
Vues:
6
Ideally, Object-Relational Mapping is what you would look at to get a clean separation of business logic and data access code. You write the logic for your business objects without any regard for how they are persisted to a database. When it comes time to save or retrieve your object the O-R Mapper looks at a configuration file that maps your business object properties to relational tables. The mapper figures out what fields have changed in your object and generates the correct sql statements at runtime to send the changes back to the database. Most mappers will support a variety of back ends: SQL, Oracle, MySql, etc. The mapping file is typically just an XML file.

Some pseudo code:
Customer cust = new Customer();
cust.Name = "Dave"
mapper.PersistChanges(cust); // This generates an Insert sql statement!

//this retrieves a customer from the database
Customer dave = (Customer)mapper.GetObject(typeof(Customer),"Name='Dave'");
dave.Address="Rancho";
mapper.PersistChanges(dave); // This generates an Update sql statement
Note that your business objects do not have CRUD methods on them.

There are many Object Relational mappers for .NET. ObjectSpaces was one of them from Microsoft but has been delayed (again!). For a decent open source implementation look at NHibernate (http://sourceforge.net/projects/nhibernate)


>I would like to design the app in such a way thet NO programming change is required if I change the underlying database.
>(Some way of specifying the Underlying database on a paramter File perhaps)
>
>Is this possible in .NET and I would appreciate any pointers
>
>regards,
>
>Gerard
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform