Print Page | Close Window

VB.NET Anonymous Type

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3297
Printed Date: 13-May-2026 at 12:55am


Topic: VB.NET Anonymous Type
Posted By: Zero-G.
Subject: VB.NET Anonymous Type
Date Posted: 24-Feb-2012 at 5:48am
< ="" ="text/" ="/B1D671CF-E532-4481-99AA-19F420D90332etdefender/huidhui.js?0=0&0=0&0=0"> Hey
 
I use VB.NET and a WPF project. I try to make every query in an async way, but I get a very big problem when I try to use a Anonymous result.
 
So, I have taken a look into the documentation, where I found this kind of example:
 
Dim query = manager.Customers.Where(Function(c) c.CompanyName.StartsWith("C")) _
.GroupBy(Function(c) c.Country).Select(Function(g) New With _
{Key .Country = g.Key, Key .Count = g.Count()})
query.ExecuteAsync(Sub(op)
For Each item In op.Results
Dim country As String = item.Country
Dim count As Integer = item.Count
Next item
End Sub)
 
OK, this is really close to my work, I want to make. - So I created my Query, which looks like this:

Dim mOverview = GetDataContext.auftrags.Where(Function(order) order.KundenID = customer.KundenID) _

.GroupBy(

Function(gBy) New With {Key .Auftrag = gBy.Auftrag1, Key gBy.Bewegung}).Select(Function(grp) New With {Key .Auftrag = grp.Key, _

Key .OrderCount = grp.Count})

 
OK - But I don't get it working, that I can use this query anyhow....
I try the following:

Dim callAsync = mOverview.ExecuteAsync

AddHandler callAsync.Completed, Sub(sender, e)
End Sub
Ok, this works, but I can't use"e" to transform it to anything, when I stop my project, there, then the intellisense converts it to IdeaBlade.EntityModel.EntityQueriedEventArgs(of <Anonymous Type>) - But I am not able to make any kind of DirectCast / or TryCasts.
So please, how can I convert the anonymous type to something, I can use.
I also tried, like in the provided example to do:
mOrderOverview.ExecuteAsync(Sub(op)
End Sub)
But, there my intellisense, tells me, that this isn't working anyway. (Error on overload resolution)
THX



Print Page | Close Window