我需要使用linq从数据库返回一些特定的列。
我尝试从子查询中获取表。
我有此查询,但我需要指定column。在我的consoleLayer中,返回数据如下:
$"Movie {program.Repertoire.MovieId.Title} in {program.Cinema.Name} " +
$"is a {program.Repertoire.MovieId.GenreBl} " +
$"playing from {program.StartOfPlaying} to {program.EndOfPlaying} " +
$"in {string.Join(", ", program.Repertoire.Hours.Select(x => x.Hour))} hours" +
$"and duration {program.Repertoire.MovieId.Runtime} minutes");
但是我不知道如何提取指定列
这是我的查询:
public async Task<ProgrammeBl> GetProgrammeByDateAndCinemaId(int cinema, DateTime date)
{
var startingWeek = StartOfPlayingRepertoir(date);
using (var context = _cinemaContext())
{
return AutoMapper.Mapper.Map<Programme, ProgrammeBl>(await context.Programme
.Include(a => a.Cinema)
.Include(x => x.Repertoire)
.Include(z => z.Repertoire.Halls.Select(x => x.CinemaHall))
.Include(u => u.Repertoire.Hours)
.Include(b => b.Repertoire.MovieId)
.Where(x => x.Cinema.Id == cinema && x.StartOfPlaying == startingWeek)
.FirstOrDefaultAsync());
}
}