Re: Sorting a Strong Typed Dataset
From: Miha Markic [MVP C#] (miha)
Date: 02/17/04
- Next message: Bob Dufour: "Limiting record numbers retrieved"
- Previous message: Scott: "Re: Fill a ComboBox"
- In reply to: Freeon: "Re: Sorting a Strong Typed Dataset"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 17 Feb 2004 21:52:24 +0100
Hi Freeon,
There are no speed improvements when using strong typed datasets. Actually,
there is a penalty of using them because strong typed dataset is derived
from dataset and has some overhead code to bring you strong type.
Of course it isn't a big penality - it is very very small.
Also, your casting is not an issue.
--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com
"Freeon" <anonymous@discussions.microsoft.com> wrote in message
news:41F4BFDF-D476-4A6A-A0C8-BBA5289A8C1E@microsoft.com...
> Thanks Miha,
>
> The cast code looks like this:
> Dim objTypedRow As CUnit.HeaderRow = CType(drHeader.Row, CUnit.HeaderRow)
> Debug.WriteLine(objTypedRow.LK_ID)
>
> Any idea if this kind of casting will offset speed improvemets gained by
using the typed datasets?
>
> Thanks again,
> Freeon
>
>
> ----- Miha Markic [MVP C#] wrote: -----
>
> Hi Freeon,
>
> Each DataRowView has Row property which you can cast to appropriate
row type
> to get strong typed rows.
>
> HTH,
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
> www.rthand.com
>
> "Freeon" <anonymous@discussions.microsoft.com> wrote in message
> news:A98ABDD2-538B-4CD8-B870-F09F7E7CBE99@microsoft.com...
> > Hi, I am looking for a way to sort a strong typed dataset. It
would seem
> the most straightforward way is to use a dataview. The only problem
is when
> I use the dataview I seem to loose the strong typed properties from
my
> original dataset.
> >> Anyone that can point me to an example of how to sort my dataset
and
> maintain the use of my typed properties would be greatly appreciated.
> >> Thank,
> > Freeon
> >> Also here is a little more detial from the orig post in the
general vb
> section:
> >> Right, I can use the .sort property change the order rows are
accessed in
> the dataview. This works great but I loose the Strong Typed Names
from the
> original dataset (unless I'm missing something) when I use the
dataview.
> >> '*************************
> > 'Here is a quick sample (Unsorted):
> > Dim drHeader As CUnit.HeaderRow
> > Dim objUnits As New CUnit(ConnectionString) 'This is a Strong
Typed
> Dataset (.xsd)
> > objUnits.Load
> >> For Each drHeader In objUnits.Header
> > Writeline drHeader.LK_ID
> > Next
> >> '*************************
> > 'Now Here is the sorted example where I loose Strong Typed
Properties from
> the Unit Dataset
> > Dim drHeader As DataRowView
> > Dim objUnits As New CUnit(ConnectionString) 'This is a Strong
Typed
> Dataset (.xsd)
> > objUnits.Load
> >> Dim dvHeader as New DataView(objUnits.Header)
> > dvHeader.Sort = "LK_id desc"
> >> For Each drHeader In dvHeader
> > Writeline drHeader("LK_ID") 'This works but I lost the
ability to
> use the typed property name (LK_ID).
> > Next
> > '*************************
> >> The second example is 90% of what I want to do.
> >> Just incase the 10% is not so clear this is how you access a
non-typed
> dataset
> > Writeline drHeader("LK_ID")
> > and this is how you access a typed dataset:
> > Writeline drHeader.LK_ID
> >>> I can't figure out how to sort a dataset while maintaining the
typed
> property names. Usually I would not care, but I have allot of class'
that
> need to be sorted a second way and don't want to rewrite all the UI
> translation code.
> >> Thanks in advance,
> > Freeon
> >>
- Next message: Bob Dufour: "Limiting record numbers retrieved"
- Previous message: Scott: "Re: Fill a ComboBox"
- In reply to: Freeon: "Re: Sorting a Strong Typed Dataset"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|