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