C# 如何在实体框架5中选择不存在的列?
我有一个查询:C# 如何在实体框架5中选择不存在的列?,c#,linq-to-entities,asp.net-web-api,entity-framework-5,C#,Linq To Entities,Asp.net Web Api,Entity Framework 5,我有一个查询: SELECT "string", Field, Field2, etc. 我希望在实体框架中模拟此操作,以便它可以与查询结果一起使用: 林克 select new { "STRING", //this is what I want to add to this. shows.ShowId, shows.Title, episodes.EpisodeId, episodes.EpisodeTi
SELECT "string", Field, Field2, etc.
我希望在实体框架中模拟此操作,以便它可以与查询结果一起使用:
林克
select new
{
"STRING", //this is what I want to add to this.
shows.ShowId,
shows.Title,
episodes.EpisodeId,
episodes.EpisodeTitle,
genres.GenreDescription,
showTypes.ShowTypeDescription,
directors.Name,
episodes.SeasonEpisode
};
如果我尝试在那里添加一个简单字符串,我会得到:
“匿名类型投影初始值设定项应为简单名称或成员访问表达式”请重试
select new
{
value = "STRING", //this is what I want to add to this.
shows.ShowId,
shows.Title,
episodes.EpisodeId,
episodes.EpisodeTitle,
genres = genres.GenreDescription,
showTypes.ShowTypeDescription,
directors.Name,
episodes.SeasonEpisode
};
你的代码有问题吗?有匿名类型投影初始值设定项应该是简单的名称或成员访问表达式“如果我希望genres.GenreDescription的标题文本是“genre”而不是“GenreDescription”,就像第一个一样
GenreDescription=genres.GenreDescription
。对不起,我首先误解了你的评论。你想要类型
,但我想反过来。请现在试一试