我有2个表,一个是Issues,另一个是JiraAssignee。问题的列名为AssigneeID
,而JiraAssignee由AssigeeID和AssigneeName组成。我需要那里的AssigneeName。
我尝试查询,但不会从JiraAssignee
表中返回值。
public ActionResult COED()
{
var model = new SO_80.Models.Tables();
string COED = "COED";
model.Issue = db.Issues.Where(d =>
model.JiraAssignee = (from d in db.Issues.Where(d => d.JiraIssueKey.Contains(COED)).ToList()
join j in db.JiraAssignees.ToList() on d.JiraAssigneeID equals j.ID
select new JiraAssignee() { DisplayName = j.DisplayName });
return View(model);
}
最佳答案
您可以使用以下代码:
public ActionResult COED()
{
var model = new SO_80.Models.Tables();
string COED = "COED";
Issue result = null;
using (Entities db = new Entities())
{
result = (from d in db.Issues
join j in db.JiraAssignees on db.Issues equals j.ID
where j.JiraIssueKey.ToLower().Trim().Contains(COED)
select d).FirstOrDefault();
}
return View(result);
}