Hi all.
I'm migrating a small app from vb6 to vb.net. It basically deals with
invoices. This is the first time I do this kind of migration, from an
existing app to a new one, the new app should be as "object oriented" as
practically possible.
I have several objects that are dependent on a database connection, such as
the Invoice, the InvoiceDetail, a Currency object (mostly used to get real
time foreign currency exchange rate, and convert between currencies), etc.
A few questions:
1) What would be the recommended way of dealing with database persistence of
those objects? For example, before persisting a new invoice I should be able
to do some validiy/consistency checks, and then insert the corresponding
database lines within the context of a transaction. This is particularly
important, I need the Invoice and its corresponding InvoiceDetail to be
created correctly, or not at all. Is there a framework that will do that for
me?
2) How to correctly model that dependency of the objects on the database? I
will probably have only one database connection active for the client, and
all the operations regarding database access should use this one. Passing a
database connection as a parameter seems quite cumbersome (for example
invoice.persist(myDatabaseConnection)) so I guess all abjects should inherit
from some kind of super object, a "Session" object or such, so they all can
use the database connection when they need to. Am I right? Is there a better
solution?
3) VB.NET has lots of facilities regarding "connecting" GUI controls
directly to database items. I don't know whether I should use the facilities
it provides, or go on a fully separated layer/oriented architecture, which
is what I'm more accustomed to.
Thanks guys, your help is mostly appreciated.