about typed datasets (conceptual question)

  • Thread starter Ersin Gençtürk
  • Start date
E

Ersin Gençtürk

hi ,

I am using ado.net with typed datasets and typed datatables
my question is about how to handle child / parent type tables with datasets.
For instance say that I have 2 tables with columns :

table Topic: (parent table)
TopicId
TopicName
CreateDate

table Message : (child table)
MessageId
TopicId
Message
CreateDate

When I need to use these 2 tables from the asp.net code I am using
databinding to bind data to a datagrid
My problem starts here because :
When I need these two tables in joined way . (say that I am listing messages
in the datagrid and I need TopicName in each row)
In classic way , it is easy join these two tables and write the necessary
databinding code.

select Message.*, Topic.TopicName from Message inner join Topic on
Message.TopicId=Topic.TopicId

But when I use typed datasets How should I fill these two tables ? ( You
can say that fill these 2 tables seperately but what if I need only the
TopicName column ? isn't it a performance decrease for the system ? do I
have to ignore it ? ) Also I would like to benefit from typed dataset
architecture.

Is there any good document or web page address about this issue ? How should
I write stored procedures ?
 
M

Miha Markic [MVP C#]

Hi Ersin,

You might consider DataColumn.Expression for this as it would be the easiest
way.
 
E

Ersin Gençtürk

hi Miha,

thanks for interest.but maybe my question was not clear enough.I am usingg
expression property to set a column to some calculated expressions , but in
this question what I want to ask was how shoul I retreive the joined tables
from the datasource (say sql) into a typed dataset in my application.

Miha Markic said:
Hi Ersin,

You might consider DataColumn.Expression for this as it would be the easiest
way.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ersin Gençtürk said:
hi ,

I am using ado.net with typed datasets and typed datatables
my question is about how to handle child / parent type tables with
datasets.
For instance say that I have 2 tables with columns :

table Topic: (parent table)
TopicId
TopicName
CreateDate

table Message : (child table)
MessageId
TopicId
Message
CreateDate

When I need to use these 2 tables from the asp.net code I am using
databinding to bind data to a datagrid
My problem starts here because :
When I need these two tables in joined way . (say that I am listing
messages
in the datagrid and I need TopicName in each row)
In classic way , it is easy join these two tables and write the necessary
databinding code.

select Message.*, Topic.TopicName from Message inner join Topic on
Message.TopicId=Topic.TopicId

But when I use typed datasets How should I fill these two tables ? ( You
can say that fill these 2 tables seperately but what if I need only the
TopicName column ? isn't it a performance decrease for the system ? do I
have to ignore it ? ) Also I would like to benefit from typed dataset
architecture.

Is there any good document or web page address about this issue ? How
should
I write stored procedures ?
 
M

Miha Markic [MVP C#]

Hi Ersin,

Ersin Gençtürk said:
hi Miha,

thanks for interest.but maybe my question was not clear enough.I am usingg
expression property to set a column to some calculated expressions , but
in
this question what I want to ask was how shoul I retreive the joined
tables
from the datasource (say sql) into a typed dataset in my application.
Why don't you create appropriate strong typed dataset that reflects your
join query and fill it using JOIN statement?
 
E

Ersin Gençtürk

hi Miha,

because there can be so many combinations of the joins.If I start creating a
type datatable for each join combination then there will be to many
datatables that I can't handle.Is there another way of doing this ? ( Also I
don't want to use untyped dataset to avoid mixture of typed and untyped
datasets)
 
M

Miha Markic [MVP C#]

Hi Ersin,

How would you use strongtyped dataset for different fields?
Strongtyped means that it knows the fields you will use and that it creates
wrapper properties for them at design time.
Take also note, that strongtyped dataset is mapped to return fields and
doesn't care about FROM or WHERE sql clauses - it return fields are the same
then you need only one strongtyped dataset.
 
E

Ersin Gençtürk

hi again Miha,

I found a great document that points my questions.

here it is :

http://msdn.microsoft.com/msdnmag/issues/02/11/datapoints/TOC.asp?frame=true


Miha Markic said:
Hi Ersin,

How would you use strongtyped dataset for different fields?
Strongtyped means that it knows the fields you will use and that it creates
wrapper properties for them at design time.
Take also note, that strongtyped dataset is mapped to return fields and
doesn't care about FROM or WHERE sql clauses - it return fields are the same
then you need only one strongtyped dataset.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

Ersin Gençtürk said:
hi Miha,

because there can be so many combinations of the joins.If I start creating
a
type datatable for each join combination then there will be to many
datatables that I can't handle.Is there another way of doing this ? ( Also
I
don't want to use untyped dataset to avoid mixture of typed and untyped
datasets)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top