Hi Guys, I am starting to work with LINQ and found some problems that the reason can be my small knolegment about the tecnology, but, its strange.
Well, when I make the following query :Code Snippet
dim x = From r in datacontext.table where r.name = "Test" select [date] = r.date.toShortDateString, r.Name
Until now, everything ok, but, when I add the Order by [date]. get the following messge.
Both DataSource and DataSourceID are defined on 'gvEvents'. Remove one definition.
Another question is that, how can I set a alias for my columns with space ? Example:Code Snippet
SQL - select name as 'My account' , 'My address' = address from Table
LINQ - ..... select [My account] = name didnt work.
Tks a lot.
ThiagoWednesday, February 13, 2008 10:16 PM
I'm by no means a LINQ expert (I just started using it yesterday) but have you tried adding the following:
dim x = From r in datacontext.table where r.name = "Test" select [date] = r.date.toShortDateString, r.Name Into TestGroup = Group Order By [date]
The other thing you could try is giving your select fields aliases before doing the order by. It would look like this I think:
dim x = From r in datacontext.table where r.name = "Test" select MyDate = r.date.toShortDateString, MyName = r.Name
I'm just learning this too so let me know if this works for you.Saturday, February 23, 2008 3:44 PM
I don't think the name [date] is in scope in your order by and the VB compiler is generating some erroneous error message. Of course, I'm guessing since you have not shown where the order-by clause is placed in your query. The select clause you are using is constructing an anonymous type with two fields, one named '[date]' and the other named 'Name'. You need something in scope that refers to the anonymous type instance before you can access the [date] field. I'd suggest adding an into clause after the select but before the order-by.
dim x = From r in datacontext.table
Where r.name = "Test"
Select [date] = r.date.toShortDateString, r.Name Into x
Order By x.[date]Sunday, February 24, 2008 12:29 AM