【发布时间】:2014-04-11 06:53:21
【问题描述】:
我有以下课程:
public class Problem
{
public Problem()
{
this.Questions = new HashSet<Question>();
this.Solutions = new HashSet<Solution>();
}
public int ProblemId { get; set; }
public string Title { get; set; }
public string Note { get; set; }
public virtual ICollection<Question> Questions { get; set; }
public virtual ICollection<Solution> Solutions { get; set; }
}
public class Question
{
public int QuestionId { get; set; }
public int ProblemId { get; set; }
public int QuestionStatusId { get; set; }
public string Note { get; set; }
public virtual Problem Problem { get; set; }
}
public class Solution
{
public int SolutionId { get; set; }
public int Number { get; set; }
public int ProblemId { get; set; }
public bool? Correct { get; set; }
public string Text { get; set; }
public string Note { get; set; }
public virtual Problem Problem { get; set; }
}
谁能帮我使用 LINQ 用于我的 EF6,1 SQL Server 2012。
我想做的是得到一个只包含数据子集的列表。在这种情况下,我希望问题、问题和解决方案实体中的 Notes 属性不从数据库中获取。
请注意,问题和解决方案表连接到问题表。我不是 100% 确定这一点,但我认为这意味着我不需要添加 .Include。
理想情况下,我希望 EF 导致问题的选择不包括 Notes 列。
【问题讨论】:
-
显示你正在训练做什么?
-
这是作业吗?你试过什么?
-
不太清楚你在这里问什么?您只想从
Problem表中选择Notes列吗? -
我想从数据库中获取除 Notes 列之外的所有内容。
标签: c# asp.net linq entity-framework sql-server-2012