What's Syntax For Orderby

May 26, 2009

I'm new to Linq, what's the syntax for orderby in VB? [code]Select distinct state from zipcodes order by State

View 2 Replies


ADVERTISEMENT

C# - OrderBy And OrderByDescending Are Stable?

Jul 30, 2009

I am currently reading Pro LINQ c# 2008, and in page 87 the guy says OrderBy and OrderByDescending are stable. But he says exactly the opposite in page 96. It looks to me as he is referring to exactly the same functions, so I don't get it. Are they stable or not?

View 2 Replies

Generic OrderBy Function?

Jun 7, 2012

I have a grid view with a lot of columns, all need to be sorted on. I have seen a few snippets out there, but I cannot get any of them to work with my example. Here is what I have so far.

Protected Sub gvSearch_OnSorting(ByVal sender As Object, _
ByVal e As GridViewSortEventArgs)
If Not Session("sort") Is Nothing Then

[code].....

View 1 Replies

.net - Linq OrderBy On Duplicate Values?

Oct 20, 2011

m_ListOfsAllFields.OrderBy(Function(x) x.DisplayOrder)

here I have DisplayOrder = 0 for 2 fields, so orderby is messing up and not ordering properly. How can I use orderby to order this collection?

View 2 Replies

Convert Lambda Expression In OrderBy Predicate From C#

Apr 24, 2012

I've got the following to sort entities by their job position. The desired order ist defined in another array. In C# this code works:[code]However I will have to convert this to VB.net. I read the equivalent would be something like the following:[code]This does not compile, gives me "Expression expected" right after the Function(x). What am I doing wrong?

View 1 Replies

Dynamic Linq .OrderBy In .Net Not Accepting Strings?

Jun 20, 2012

I'm having a problem implementing Scott G's Dynamic.vb extension at [URL] in my vb solution. I've searched StackOverflow (80+ Q&As) and numerous other sites without much luck. I'm using VS 2010.I've included Dynamic.vb in a problem with no root namespace, and then added a reference to that project in my main one. I'm getting intellisense for 4 overloads (rather than 2) so I'm pretty certain that the extension is in scope.I was having a tough time with clauses, especially the OrderBy as Scott demonstrated. If I simply pass a string as Scott's VB example did I get the error "Overload resolution failed because no accessible 'OrderBy' can be called with these arguments."

The line of code is:

Dim FilteredComponentList = From Component As MX.Component In ComponentList.AsQueryable _
.OrderBy("Name")

So I found other references that stated to pass a Lambda expression. So I tried this and at least I get no error, even if the sort function still doesn't seem to work. Here is the code that compiles and executes.

Private Sub SortByColumn()
If Not cmbComponentFilter.SelectedItem.ToString = "All" Then
Dim FilteredComponentList = From Component As MX.Component In ComponentList.AsQueryable _

[code]....

When I interrogate the dgvComponents.Columns(e.ColumnIndex).Name it gives the objects property I wish to sort by, but the sort still isn't working. I'm concerned why I can't get Scott's implementation to work, but I've heard his keynotes and read his blogs, so I'm guessing the problem lies with my implementation.

I'd like either to work but need to understand why as well. Why doesn't passing a string work? Isn't the PARAMARRAY declared in the function optional?

View 1 Replies

IQueryable OrderBy Error: Cannot Order By Comparer

Sep 14, 2011

I'm trying to sort a IQueryable dynamicaly.

Dim activities =From a In db.VW_Activities Select a
activities = activities.OrderBy(Function(a)
New ActivityComparer(SortFields(0).Sort))
definition of SortFields:

[Code]...

View 3 Replies

Pass A Lambda Function To Linq's Orderby?

Jan 24, 2010

I am trying to pass a lambda function to Linq's orderby and cannot get it to work.

The relevant code is:

Dim myordering = Function(m) m.Count
If isAlphaOrder Then
myOrdering = Function(m) m.Key 'Order by Alphabet

[Code].....

View 4 Replies

VS 2010 Struggling With OrderBy Lambda Expression?

Aug 24, 2011

I'm getting my feet wet with Lambda expressions and it's rather overwhelming.I have a UserPrincipal object called SelectedUser. I wish to get a sorted list of the user's groups This is what I have so far but when I include that code my application's form flashes a few times and closes! Also, what is the significance of the "r" in the "Return From r" statement?

Dim SortedGroups As PrincipalSearchResult(Of Principal) = GetSortedGroups(Me.SelectedUser.GetGroups())
Private Function GetSortedGroups(ByVal psp As PrincipalSearchResult(Of Principal)) As PrincipalSearchResult(Of Principal)
Return From r In psp.OrderBy(Function(t) t.Name)
End Function

View 4 Replies

LINQ Query With Multiple OrderBy Statements Added In Loop

May 11, 2012

I have a method in a webservice that has parameter with which users can decide how they want to order their results. This is a List(Of String) with the names of the fields in the order they want to sort them. I know I can normally order on multiple columns by doing the following

Dim test = Bars.OrderBy(Function(x) x.Foo) _
.ThenBy(Function(x) x.Bar) _
.ThenBy(Function(x) x.Test)

However in this case this won't work since I can't chain the ThenBy function because I'm adding the sorting orders in a loop. To use ThenBy I need an IOrderedQueryable collection. This is how I would want it to work

Dim sortColumns = {"Foo", "Bar", "Test"}
Dim query = From b in Bars
For each column in sortColumns
Select Case column
Case "Foo"
query = query.Orderby(Function(x) x.Foo)
[Code] .....

View 1 Replies

OrderBy Nullable Properties In A Generic List Throwing InvalidCastException?

Jun 13, 2012

I need to return an a generic list in the correct order for my project, and I'm getting InvalidCastException errors. Here is the code:

Dim lDt As List(Of Comment) = RemapCommentsForE1(so.CommentList). _
OrderBy(Function(x) x.CreateDate.Value). _
ThenBy(Function(x) x.Sequence). _

[code].....

View 2 Replies

Conditional OrderBy - Number Of Columns User Can Sort By (Name, County, Active)

Jun 17, 2010

I've got a number of columns the user can sort by (Name, County, Active) and that's easy but messy. Looks something like this...

Select Case e.SortExpression
Case "Name"
If (isDescending) Then

[CODE]...

What I would LIKE to do, is something more ... like this

Private Function SortThatList(ByVal listOfStuff As List(Of Stuff), ByVal isDescending As Boolean, ByVal expression As Func(Of Stuff)) As List(Of Stuff)
If (isDescending) Then

[CODE]...

But it doesn't like the datatype (Of TKey) ... I've tired Func(Of stuff, boolean) (got something in c# that works nicely like that) but can't seem to get this one to do what I want.What's the magic syntax?

View 2 Replies

Syntax/Command Trying To Implement Syntax Highlighting In RichTextBox?

Oct 12, 2011

I am having an issue trying to figure this out. I am writing a script editor that uses tabs (a tab control) and I want to implement syntax highlighting. My issue is that every sample I can find on syntax highlighting uses

Private Sub RichTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

View 1 Replies

C# - Syntax Conversion - Translate Syntax ?

Dec 16, 2009

Can any one translate the following syntax to vb.net.

m_TextBox.Loaded += TextBoxLoaded
m_TextBox.Loaded -= TextBoxLoaded;
private void TextBoxLoaded(object sender, RoutedEventArgs e)[code].....

View 4 Replies

Use "orderby" Filling A Grid?

May 16, 2011

What is the correct way of writing this?

Me.QuickViewTableAdapter.Fill(Me.PVDBDataSet.QuickView.OrderBy(0))

I'm trying to control the order of a specified column. But I need to this in code, not through the designer.

View 3 Replies

Convert Late Binding Syntax To Early Binding Syntax In .net?

Sep 5, 2011

i have this code:Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[Code]...

Error 1: Option Strict On disallows late binding.Im using visual basic 2010 express on a gateway laptop thats running Windows 7 OS How do i resolve this error?

View 2 Replies

Convert Late Binding Syntax To Early Binding Syntax?

Apr 9, 2009

I have a listbox and it it I am showing numbers.It should look like this (line by line) 1,2,3,4,5,6,7,8,9,10,11.....but is is showing it like this 1,10,11,...2,20,21...3,30...ow can I make it that it will show it in number order 1,2,3,4,5......

View 5 Replies

Syntax Error: Syntax Error: Missing Operand After '14' Operator

Oct 21, 2009

I want to select some rows from a sql express 2005 table. I am using this expression: "Starttime >= " & dtpStart.Value dtpStart is a DateTimePicker But I am getting this error: Syntax error: Missing operand after '14' operator.

View 18 Replies

Asp.net - Regarding Syntax In C# And Vb

Aug 7, 2009

I have a web service in c# and its working well in c#.Following is one method i used in it

[WebMethod(EnableSession = true)]
public void abc(BllNew objNew)
{
new DAL.Entity.BllNew().sample();
}

But again i implemented above method in vb and is like this

[WebMethod(EnableSession = true)]
public void abc(BllNew objNew)
{
new DAL.Entity.BllNew().sample();
}

One syntax error is showing near 'new' keyword.What change i hve to get rid of syntax error.

View 2 Replies

C# Syntax To A Vb-er

Sep 11, 2009

I have the following code snippet:

CODE:

I do not understand the

CODE:

Can someone explain it? For the record...dropOperation is an enum. Can you give vb syntactical equivalent is all I need.

View 10 Replies

Sql Syntax To Always Get One?

May 25, 2011

SELECT dbo.Calls.Description, dbo.TicketRead.IsRead, dbo.TicketRead.UserID
FROM dbo.Calls
LEFT OUTER JOIN dbo.TicketRead ON dbo.Calls.CallID = dbo.TicketRead.TicketID
WHERE dbo.TicketRead.UserID = 1 or is null

I want to get a list of all calls, but also a value indicating if the user have read the call. so I made when a user open's the ticket a new record is added in a special table. now if no user have read it then it's ok, but if just one user have read this ticket, then the other users don't have this call in the list..

View 2 Replies

Syntax For An Old Vba?

Apr 29, 2012

just starting out to learn vb.net. I am doing so cuz i have some vba stuff i need to port.orry for the beginner question: translate this code I use in Outlook to vb.net? I know it's not complete, but I am stuck here.

Private Sub Application_ItemSend(ByVal Item As Object, ByVal Cancel As Boolean)
Dim objNS As NameSpace
im objFolder As MAPIFolder

[code]....

View 1 Replies

Wcf - What Is This Syntax In .NET

Feb 6, 2012

The following is from a WCF sample I am working on.

<ServiceBehavior(InstanceContextMode:=InstanceContextMode.Single)> _
<Foobar()> _
Public Class Service1

I've never understood this and just used examples, but I would like to understand what is going on here. What exactly is the stuff inside the <> brackets? How are these related to Service1? I understand the ServiceBehavior is related to the hosting, but what about Foobar?

View 2 Replies

ASP VB Syntax Error?

Jun 7, 2012

I'm trying to display an aggregate feed of several RSS feeds. I'm doing this with an asp page.The problem is I'm getting the error message:Microsoft VBScript compilation error '800a0401' Expected end of statement for the line:Dim feed As SyndicationFe

View 1 Replies

Asp.net - SQL: Incorrect Syntax Near

Apr 7, 2011

I used to have this one

Dt = MyMod.GetDataTable("SELECT TOP " & QuestionsPerCats(i) & " * From Questions WHERE CategoriesID ='" & Cats(i) & "' ORDER BY NEWID()")

but now i decided to use sqlparameters like

Dim cmd As New SqlCommand("SELECT TOP @QuestionsPerCats * From Questions WHERE CategoriesID = @CategoriesID ORDER BY NEWID()", conn)
Dim sqlParam As SqlParameter = Nothing
sqlParam = cmd.Parameters.Add("@QuestionsPerCats", SqlDbType.SmallInt)

[code]....

and returns the following error

Incorrect syntax near '@QuestionsPerCats'.

View 3 Replies

Can't Get A Handle On The Syntax?

Aug 6, 2009

I can't get a handle on the syntax. Can anyone give me a simple demo?

View 3 Replies

Checking VB Syntax

Mar 12, 2012

i hope to create an application to check vb.net syntaxes (for simple function or methoe). Application will be given richtext box to add function or method and when submit, need to check that vb.net syntax and it will be execute by powershell.

View 1 Replies

Difference Between The Following Syntax?

Jun 16, 2010

Is there any differnce between the following syntax? Im thinking that there isnt, as long as the end result of the "AS" portion has RuleType named "AS R.RuleType." Notice that the first snippet of code has the R.RuleType and the second has just Rule.Type.strRule.Append(

"select R.Ruleid,R.RuleNumber,isnull(C.ClientName,'') as ClientName,R.Customerid,Case R.RuleType when 'R' then 'P' when 'B' then 'G' else R.RuleType End as R.RuleType,isnull(C.InternalClientID,'')
as InternalClientID,")

[Code]...

View 2 Replies

Get A Syntax Error?

Apr 27, 2009

im trying to do a basic calculation and i get a syntax error on what ever if first on the bottom line of this code :

[code].....

at the error is on the bracket on the bottom line but when i remove it , the error goes onto the 805 .everything is declared properly in a module. as integers?

View 2 Replies

How Is VB6 Different From .NET In Terms Of Syntax

Apr 9, 2010

How is VB6 Different from VB.NET in terms of Syntax? what is their relationship and major differences?.

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved