我试图理解LINQ查询的语法。我尝试创建一个来从我的TRACK_INFO表中选择所有行,其中columnOf列等于变量。我的数据库名称是KuPlan。下面是我试图创建的查询和我的TRACK_INFO模型。我得到的错误是:"找不到源类型KU_PLAN_DEV.Models.TRACK_INFO的查询模式的实现。 '凡'没找到。"
控制器:
var query = from degreeName in TRACK_INFO
where degreeName == trackButton
select degreeName;
模型:
namespace KU_PLAN_DEV.Models
{
using System;
using System.Collections.Generic;
public partial class TRACK_INFO
{
public TRACK_INFO()
{
this.CORE_HEAD = new HashSet<CORE_HEAD>();
this.GEN_ED_HEAD = new HashSet<GEN_ED_HEAD>();
this.GEN_ED_NOTE = new HashSet<GEN_ED_NOTE>();
this.GRAD_CLEAR_HEAD = new HashSet<GRAD_CLEAR_HEAD>();
this.MAJOR_NOTE = new HashSet<MAJOR_NOTE>();
}
public string progNum { get; set; }
public string versionNum { get; set; }
public string degreeName { get; set; }
public string collegeOf { get; set; }
public string effectiveDateTerm { get; set; }
public Nullable<decimal> effectiveDateYear { get; set; }
public string trackDegreeType { get; set; }
public virtual ICollection<CORE_HEAD> CORE_HEAD { get; set; }
public virtual ICollection<GEN_ED_HEAD> GEN_ED_HEAD { get; set; }
public virtual ICollection<GEN_ED_NOTE> GEN_ED_NOTE { get; set; }
public virtual ICollection<GRAD_CLEAR_HEAD> GRAD_CLEAR_HEAD { get; set; }
public virtual GRAD_CLEAR_SIG_DATE GRAD_CLEAR_SIG_DATE { get; set; }
public virtual ICollection<MAJOR_NOTE> MAJOR_NOTE { get; set; }
}
}
答案 0 :(得分:1)
TRACK_INFO
是一个类名,而不是IEnumerable<TRACK_INFO>
。我想你的意思是从你的背景中获取一个属性:
from degreeName in context.TRACK_INFO
...