Datasets and merging

  • Thread starter Thread starter Jonas
  • Start date Start date
J

Jonas

Hi!

I want to extract a single row from one table in a typed dataset (dsUser)
containing multiple tables, and then send it on to a data access layer
component for create/read/update/delete operations. I found two ways:

1. Create a standalone typed dataset (dsPerson) with the same structure as
the one table I'm interested in, and use the Merge function to get the
content of the datatable.

dsPerson.Merge(dsUser.COR_Persons)

2. Extract the row by using the ItemArray property of the
dsPerson.COR_Persons and dsUser.COR_Persons datatables respectively.

Dim dsPerson As New COR_Persons
Dim personRow As COR_Persons.COR_PersonsRow

personRow = dsPerson.COR_Persons.NewCOR_PersonsRow
personRow.ItemArray = dsUser.COR_Persons(0).ItemArray

The first approach is the easiest implement, but I get a bulkier object to
send on the data access layer.

Does someone now anything about the performance differences for these two
approaches?

TIA

Jonas
 
Jonas,

The below is a little tricky to answer, Approach 2 will probably be faster,
but really by how much?? The only way you can find out for sure is by
writing up a quick sample yourself and running it in a loop.

Do remember that the "bulky" dataset you need to pass to your data access
layer, is nothing more than a copy of a pointer reference that you pass
(i.e. the entire object is not copied over and over again), so while it may
occupy some space in memory, that much space is occupied only once.

And then there's the question of "The lesser code you write, the lesser rope
you have to hang yourself with", in other words, even if the performance is
a little bit below desirable, given code readability, maintainability, you
might choose to pick one solution over the other.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
 
Thanks for your answer, Sahil.

I'm kind of leaning towards the first approach, and then the code can be
optimized later on if needed.

Brgds

Jonas
 
Back
Top