Translation. Could someone, please, help me?

S

shapper

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
 
D

David Anton

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()

--
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top