G
Guest
Hi,
I have a business-entity-classes which are constructed of few primitive
types and one DataSet type. For Example:
Public class MyClass{
private int id;
private string name;
private DataSet childrenCollection;
…
In my data access layer I want to create an instance based on this class and
fill it with data from the DB (MSDE). I have two options in mind and I want
to know which would be the best in term of performance. In both options I’m
using a single stored procedure with two select statements – one for the
single row (primitive types) and one for the children collection. For example:
SELECT ID, Name from T_Parents WHERE ID= id;
SELECT ID, Name from T_Children WHERE ParentID = id;
The options are:
1. Fill all the data into a DataSet. As there are two select statements two
tables will be created in the DataSet I would be able to copy the values from
the first table to my class primitive and the other table to my class
DataSet.
2. Use a DataReader and, by looping over the second ResultsSet, build a
DataTable row after row. So instead of using the DataSet.Fill method I’ll be
“manually†creating the rows and inserting the values based on the results
coming from the DataReader.
I don’t think it matters, but I’m using the data access application bloc v2.
If there is another (better) option I haven’t thought about I’ll be happy to
know. Otherwise I would like to know which one should perform better.
Thank you,
Gwenda
I have a business-entity-classes which are constructed of few primitive
types and one DataSet type. For Example:
Public class MyClass{
private int id;
private string name;
private DataSet childrenCollection;
…
In my data access layer I want to create an instance based on this class and
fill it with data from the DB (MSDE). I have two options in mind and I want
to know which would be the best in term of performance. In both options I’m
using a single stored procedure with two select statements – one for the
single row (primitive types) and one for the children collection. For example:
SELECT ID, Name from T_Parents WHERE ID= id;
SELECT ID, Name from T_Children WHERE ParentID = id;
The options are:
1. Fill all the data into a DataSet. As there are two select statements two
tables will be created in the DataSet I would be able to copy the values from
the first table to my class primitive and the other table to my class
DataSet.
2. Use a DataReader and, by looping over the second ResultsSet, build a
DataTable row after row. So instead of using the DataSet.Fill method I’ll be
“manually†creating the rows and inserting the values based on the results
coming from the DataReader.
I don’t think it matters, but I’m using the data access application bloc v2.
If there is another (better) option I haven’t thought about I’ll be happy to
know. Otherwise I would like to know which one should perform better.
Thank you,
Gwenda