2016-04-18 21 views
0

Ich habe diese Abfrage und ich wollte nur bestimmte Wert von Charges Tabelle (Port-Name muss nur einmal angezeigt werden).Wählen Sie einen Datensatz aus Join-Tabelle

public List<Port> GetPortsByCountryOrigin(int countryId, TransportDirection transdirection, TransportType transtype) 
    { 
     using (var ctx = CreateDbContext()) 
     { 

      return (from item in ctx.Ports 
        join s in ctx.Charges 
        on item.PortId equals s.PortId 
        where (s.TransportDirection == transdirection && 
        s.TransportType == transtype 
        && item.CountryId == countryId) 
        select item).ToList(); 
     } 
    } 

Derzeit sind die Ports.Name Werte wiederholen.

Antwort

1

Versuchen Sie .Distinct() vor Ihrer ToList()

Verwandte Themen