0

我试图加入那些表我必须使用动态 linq,如果.Join(dbcontext.Providers)有并且当我在.Join(dbcontext.Providers)上没有数据时返回数据 所有queryResolts returnig 0结果

即使其中一个连接返回 0 结果,我如何获取数据

var queryResolts = dbcontext.Tracks
            // Add Services
            .Join(dbcontext.Services,
                track => track.ServiceId,
                service => service.ServiceId,
                (track, service) => new { Track = track, Service = service })
            // Add ServiceInterfaces
            .Join(dbcontext.ServiceInterfaces,
                ts => ts.Track.ServiceInterfaceId,
                serviceInterface => serviceInterface.ServiceInterfaceId,
                (ts, serviceInterface) => new { Track = ts.Track, Service = ts.Service, ServiceInterfaces = serviceInterface })
            // Add Providers
            .Join(dbcontext.Providers,
                tss => tss.Track.ProviderId,
                provider => provider.ProviderId,
                (tss, provider) => new { Track = tss.Track, Service = tss.Service, ServiceInterfaces = tss.ServiceInterfaces, Providers = provider })
            .Where("ServiceInterfaces.ServiceInterfaceName == @0", "PublishPolicyInterface2")
            .Select(y => y.Track) 

            ;

谢谢

三木

4

1 回答 1

1

Join这里的工作方式与joinin类似SQL,如果连接的表不包含结果,它将不会返回任何值。

如果您需要,请left or right outer join使用GroupJoin().

于 2012-10-23T13:02:25.477 回答