0

SQL クエリ:

SELECT   

'ETS' AS dataSource, 
ES.ShowId, 
ES.Title, 
EE.EpisodeId, 
EE.Title AS EpisodeTitle, 
ELG.GenreDescription 
AS Genre, 
ELST.ShowTypeDescription, 
dbo.TVData_UDF_ETS_DirectorString(ES.ShowId) AS DirectorName, 
ES.ReleaseYear, 
EE.SeasonEpisode

FROM dbo.ETS_Shows AS ES 
LEFT OUTER JOIN dbo.ETS_Episodes AS EE 
ON ES.ShowId = EE.ShowId 

LEFT OUTER JOIN dbo.ETS_LKP_Genres AS ELG 
ON ES.GenreCode = ELG.GenreCode 

LEFT OUTER JOIN dbo.ETS_LKP_ShowTypes AS ELST 
ON ES.ShowTypeCode = ELST.ShowTypeCode

これを実行しようとしていますが、正しいデータが返されません:

var data = db.ETS_Shows.Include("ETS_Episodes").Include("ETS_LKP_Genres").Include("ETS_LKP_ShowTypes").ToList();

誰か手を貸してくれませんか?

4

1 に答える 1

0

私はそれを考え出した:

var query = from shows in db.ETS_Shows
                        from episodes in db.ETS_Episodes.Where(v => v.ShowId == shows.ShowId).DefaultIfEmpty()
                        from genres in db.ETS_LKP_Genres.Where(s => s.GenreCode == shows.GenreCode).DefaultIfEmpty()
                        from showTypes in db.ETS_LKP_ShowTypes.Where(z => z.ShowTypeCode == shows.ShowTypeCode).DefaultIfEmpty()
                        from directors in db.ETS_Directors.Where(p => p.ShowId == shows.ShowId).DefaultIfEmpty()
                        select new 
                            {
                                dataSource = "ETS",
                                shows.Title,
                                episodes.EpisodeId,
                                episodes.EpisodeTitle,
                                genres.GenreDescription,
                                showTypes.ShowTypeDescription,
                                directors.Name,
                                shows.ReleaseYear,
                                episodes.SeasonEpisode,
                                shows.ShowId
                            };
于 2013-06-20T16:06:30.990 に答える