Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

Translation. Could someone, please, help me?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 05 Mar 2008 23:23 GMT
Hello,

I am trying to translate a LINQ query in C# but I am having problems
in getting it right.

Could someone, please, help me? The online converters do not work with
LINQ.

C#

   var counts = ctx.Customers.Select(x =>
   new
   {
       Total = ctx.Customers.Count(),
       Linked = ctx.Customers.Where(
           cust => cust.CustomerCustomerDemos.Any()
           || cust.Orders.Any()).Count()
   }).FirstOrDefault();

VB.NET

     Dim counts = From x In ctx.Customers.Select( _
     Function(x) _
       Total = ctx.Customers.Count(), _
       Linked = ctx.Customers.Where( _
         Function(cust) _
           cust.CustomerCustomerDemos.Any Or
cust.Orders.Any).Count).FirstOrDefault

What am I doing wrong?
It says Linked is not declared ...

Thanks,
Miguel
David Anton - 06 Mar 2008 01:28 GMT
Try:
Dim counts = ctx.Customers.Select(Function(x) New With {Key .Total =
ctx.Customers.Count(), Key .Linked = ctx.Customers.Where(Function(cust)
cust.CustomerCustomerDemos.Any() OrElse
cust.Orders.Any()).Count()}).FirstOrDefault()

Signature

http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
Java to C#
Java to VB
Instant C#: convert VB to C#
Instant VB: convert C# to VB
Instant C++: VB, C#, or Java to C++/CLI

> Hello,
>
[quoted text clipped - 30 lines]
> Thanks,
> Miguel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.