473,320 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Linq query's sorted properties

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...
Aug 20 '08 #1
3 1896
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
Aug 20 '08 #2
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 :)

Aug 21 '08 #3
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 :)

Sep 1 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: WebSnozz | last post by:
Some collections are such that efficient search algorithms work on them such as binary search if the collection is a type which is sorted. I'm wondering how LINQ searches these collections and if...
28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
15
by: EDBrian | last post by:
My problem is this. Our clients create different fields they want to collect and we allow them build dynamic filters, reports etc... We run some TSQL to actually create the column and all works...
8
by: Andy | last post by:
Hi, I'm trying to add a where clause to my query: List<stringtypes = new List<string>(); types.Add( "A" ); types.Add( "B" ); query = query.Where( c =types.Contains( c.Type ) );
0
by: Lloyd Sheen | last post by:
I was in a thread talking about how to populate a listview from a Linq query. This got my curiosity up so I created a usercontrol which is a listview which can be populated from a Linq query. I...
14
by: thj | last post by:
Hi, I was wondering what you guys are using and why? LINQ to SQL or NHibernate? Thanks in advance, Tommy
21
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
2
by: shapper | last post by:
Hello, I have the following Linq query: List<PostsTaginsert = (from t in (from t in database.Tags join p in paper.Tags on t.Name equals p.Name select t).ToList() select new PostsTag {
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.