Pregunta

Tengo país => ligue => equipo (nombre, puntaje)

Necesito seleccionar todas las puntuaciones de nombre del equipo de un país.

algo como esto, no funciona)

consulta = de liga en mycountry. Ligas, de equipo en liga.teams Seleccione nombre = nombre del equipo, puntaje = equipo. distinto

EDITAR:

La sintaxis VB.NET es preferible.

¿Fue útil?

Solución 3

Usando el código de Jeroenh, que usó el código de Kirk, aquí está la versión de trabajo (vb.net)

  Dim query =  From ligue In myCountry.Ligues
               From team In ligue.Teams
               Select Name = team.Name, Score = team.Score 
               Distinct

Otros consejos

Debería poder hacer un simple select / selectMany

context.Countries.Single(c => c.CountryName == "My Country")
    .Ligues.SelectMany(ligue => ligue.Teams
        .Select(team => new { team.Name, team.Score }))
        .Distinct();

Aquí está el código de KIRK traducido a la sintaxis del método de extensión VB10:

dim result = context.Countries.Single(Function(c) c.CountryName = "My Country").
               Ligues.SelectMany(Function(ligue) ligue.Teams).
                      Select(Function(team) new with {team.Name, team.Score }).
                      Distinct()

Creo que (pero no estoy seguro, no tenga acceso a un compilador VB en este momento) puede escribirlo como esta sintaxis de consulta VB.NET

(Editar mi prueba original fue realmente incorrecta, así que corrigí la consulta a continuación :)

dim result = From ligue in myCountry.Ligues
             From team in ligue.Teams
             Select team.Name, team.Score Distinct
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top