S
Sky
Hello:
Looking for some insight into using Persistent Data Objects instead of SQL
calls everywhere, but have a couple of arch. questions I don't
get/understand.
a) For each table (eg: Customers) one has a class called cCustomers. The
basics are that instead of Connection.Open(), DataReader, etc. one simply
can cCustomers.Load(tGUID); using a function to map the database recordset's
fields to the classes properties, populating that class with a record. And
after changes are made to a Property, reversing the process to build an
insert or Update statement via reflection, and synch it back to the db.
As for working with a group of them use a cCustomerCollection based on
IList, and one can also just as easily use it as a DataSrc for a
aspataGrid or other. Nice. Very nice.
But what I don't get, and worries me a bit is:
a) Scenario: User A loads a cCustomerCollection (WHERE NAME LIKE 'S%') of
cCustomer objects. Then comes along User B who loads the same or other
cCollection (WHERE NAME LIKE 'SMI%'). At this point the sever has two
collections in memory. Ok. Now, User A modifies the properties of one of the
cCustomers in his cCustomerCollection, and Synch()'s it back to the DBMS.
Great. Except -- and here is my question -- it appears to me that UserB will
now be looking at an out of date Record! How can one guarantee persistent
synchronized data across users????? If you could explain how this works, or
what to do to make it possible, or why it is NOT important to have this work
this way I would feel a Lot better about using the approach.
b) Secondly scenario that I use a lot: if you have cCustomers, and
cPermissions, and generally I Join these together so that I have one
virtual table to display with, and choose whether to display a record, line
by line, then how does one approach this via persitent DataObjects? If we
do this by first querying for cCustomers to get a cCustomerCollection, do we
then have to requery for each cCustomer.Permissions !???! This would to
increase the number of sql calls dramatically. Or does one still build an
Join statement like before, but resplit the resulting recordset into two
objects: cCustomers, and it's related cRights? Or another technique? Ie: how
many calls would it take to do the above? Or is this not a good scenario for
Persistent Data Objects?
Anyway - sorry for the sort of complex questions -- but the few code
examples of PDO I've found have concentrated on the very basics (ie Mapping
and Synching), but not the common day-to-day problems that I deal with
currently with SQL.
Any and all help greatly appreciated!!!
PS: I've purchased "Data Access Patterns" by Nock -- but it didn't address
these two issues as far as I can tell, and I downloaded DNN 2.0 to see how
theirs approach is implemented -- but it has proved a little to intricate
for me to figure out what's going on under the hood -- does anyone know of a
good web article or other source that starts from basics and goes into
detail on how to write a PDO layer?
Thanks!
Looking for some insight into using Persistent Data Objects instead of SQL
calls everywhere, but have a couple of arch. questions I don't
get/understand.
a) For each table (eg: Customers) one has a class called cCustomers. The
basics are that instead of Connection.Open(), DataReader, etc. one simply
can cCustomers.Load(tGUID); using a function to map the database recordset's
fields to the classes properties, populating that class with a record. And
after changes are made to a Property, reversing the process to build an
insert or Update statement via reflection, and synch it back to the db.
As for working with a group of them use a cCustomerCollection based on
IList, and one can also just as easily use it as a DataSrc for a
aspataGrid or other. Nice. Very nice.
But what I don't get, and worries me a bit is:
a) Scenario: User A loads a cCustomerCollection (WHERE NAME LIKE 'S%') of
cCustomer objects. Then comes along User B who loads the same or other
cCollection (WHERE NAME LIKE 'SMI%'). At this point the sever has two
collections in memory. Ok. Now, User A modifies the properties of one of the
cCustomers in his cCustomerCollection, and Synch()'s it back to the DBMS.
Great. Except -- and here is my question -- it appears to me that UserB will
now be looking at an out of date Record! How can one guarantee persistent
synchronized data across users????? If you could explain how this works, or
what to do to make it possible, or why it is NOT important to have this work
this way I would feel a Lot better about using the approach.
b) Secondly scenario that I use a lot: if you have cCustomers, and
cPermissions, and generally I Join these together so that I have one
virtual table to display with, and choose whether to display a record, line
by line, then how does one approach this via persitent DataObjects? If we
do this by first querying for cCustomers to get a cCustomerCollection, do we
then have to requery for each cCustomer.Permissions !???! This would to
increase the number of sql calls dramatically. Or does one still build an
Join statement like before, but resplit the resulting recordset into two
objects: cCustomers, and it's related cRights? Or another technique? Ie: how
many calls would it take to do the above? Or is this not a good scenario for
Persistent Data Objects?
Anyway - sorry for the sort of complex questions -- but the few code
examples of PDO I've found have concentrated on the very basics (ie Mapping
and Synching), but not the common day-to-day problems that I deal with
currently with SQL.
Any and all help greatly appreciated!!!
PS: I've purchased "Data Access Patterns" by Nock -- but it didn't address
these two issues as far as I can tell, and I downloaded DNN 2.0 to see how
theirs approach is implemented -- but it has proved a little to intricate
for me to figure out what's going on under the hood -- does anyone know of a
good web article or other source that starts from basics and goes into
detail on how to write a PDO layer?
Thanks!