T
Trapulo
I've an application that internally manages data as user-defined business
objects (classes). This objects are saved and readed to/from a sql server
db. My DAL layer executes SPs using datareaders, and creates objects that
the application uses from result sets.
My problem is about the best way to retrieve data in master-details
scenarios.
Eg:
public class Object1
public p1 as int16
public d1 as detailsCollection
public d2 as detailsCollection
end class
DetailsCollection is a class that inherits collectionbase and that contains
a set of other objects.
On my db this is mapped as
table object1 (ID, p1)
table d1 (ID, object1_ID, other data)
table d2 (ID, object1_ID, other data)
I need an efficient way to read this data. I cannot read a set of objects
from table "object1" and then, for each row, read corresponding data from
tables "d1" and "d2", because this will result in a lot of different select
commands to sql server, and very bad performance.
I've tried to use a single query with a join, and then "split" result to
different objects. This works (anyway doesn't result in a very beautiful
code) and it is a lot faster, but I've problems when my object has a lot of
"details" (details from different tables).
What is an efficient solution I can use for this scenario?
thanks
objects (classes). This objects are saved and readed to/from a sql server
db. My DAL layer executes SPs using datareaders, and creates objects that
the application uses from result sets.
My problem is about the best way to retrieve data in master-details
scenarios.
Eg:
public class Object1
public p1 as int16
public d1 as detailsCollection
public d2 as detailsCollection
end class
DetailsCollection is a class that inherits collectionbase and that contains
a set of other objects.
On my db this is mapped as
table object1 (ID, p1)
table d1 (ID, object1_ID, other data)
table d2 (ID, object1_ID, other data)
I need an efficient way to read this data. I cannot read a set of objects
from table "object1" and then, for each row, read corresponding data from
tables "d1" and "d2", because this will result in a lot of different select
commands to sql server, and very bad performance.
I've tried to use a single query with a join, and then "split" result to
different objects. This works (anyway doesn't result in a very beautiful
code) and it is a lot faster, but I've problems when my object has a lot of
"details" (details from different tables).
What is an efficient solution I can use for this scenario?
thanks