473,657 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetProper ties()
.... 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 1909
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.GetProper ties()
... 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 DataPropertyNam e 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.cwrot e:
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.GetProper ties()
... 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 DataPropertyNam e 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.c omwrote in message
news:4e******** *************** ***********@i76 g2000hsf.google groups.com...
On 20 août, 20:44, Lloyd Sheen <a...@b.cwrot e:
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.GetProper ties()
... 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 DataPropertyNam e 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
2631
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 it takes advantage of the fact that some collections are sorted? We were speculating that the standard .net 2.0 collections might implement the IQueryable interface for those collections where there are more efficient search algorithms.
28
16384
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 write a safe but easy implementation (i.e. no codedom) for an IBindingListView.Filter (by compiling to a Predicate<T>). Anybody know if this is possible at all? Marc
15
10850
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 very well. We are now adding a lot more functionality to our filters and could really benefit from using the LINQ to SQL. I have experimented with the Dynamic Linq...
8
46867
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
931
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 has all the same properties / methods available to a listview but behind the scenes it is really a virtual listview. It is quick to load (33K items in less than a second including the query). It can be sorted and uses the dynamic linq vb...
14
3671
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
4351
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
2
2394
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
8316
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8833
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8509
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8610
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7345
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4168
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1730
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.