Vivien,
Have you tried your code under VS2008 SP1 (.NET 3.5 SP1).
There's a bug in VS 2008 (.NET 3.5) that causes an anonymous type's
properties to be sorted. I tried a quick sample under VS 2008 SP1 (.NET 3.5
SP1) and it appears the bug has been fixed.
--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
"Vivien Parlat" <po****@gmail.comwrote in message
news:4e**********************************@i76g2000 hsf.googlegroups.com...
On 20 août, 20:44, Lloyd Sheen <a...@b.cwrote:
Vivien Parlat wrote:
Hello,
I am currently using VB.Net 2008 express. I use linq to perform
queries on a database, and I'm using the following link's source to
convert those queries into DataTables i can then bind to WinForms'
DataGridViews:
http://blogs.msdn.com/aconrad/archiv...e-project.aspx
The point is, the properties names extracted by the following lines:
_type = GetType(T)
_pi = _type.GetProperties()
... are sorted alphabetically !
I cannot figure out how to keep them "unsorted", ie sorted as they are
in my Select clause.
Can anyone help me ?
Thanks a lot in advance...
Vivien,
First question is why are you using DataTables when you can bind using
the objects created in the Linq query. If you set up your DataGridView
with columns and set the DataPropertyName then binding the data will
show the data from your query correctly.
LS
I'm using Datatables because I'm trying to modify someone's code, and
the previous developers have isolated all linq queries in a single
dll, each one having its own Function returning a DataTable, and each
one ending with a call to CopyToDataTable or to previously quoted
ToDataTable method.
As far as (I (believe) I know, anonymous type cannot be used in
parameters or return values, so I could not find out good and simple
replacement method. Maybe I am wrong, which could help me much :)