我已经将Scott的这个教程与T对照我自己的数据库。
我在Partial类中遇到错误。
当前上下文中不存在名称“ExecuteQuery”。我不能为我的生活弄清楚出了什么问题。
public partial class MerchantsAppDataContext
{
public IEnumerable<SubmittalDetails> GetSubmittalDetails(string minDate)
{
var sqlTxt = "SELECT Submittals.SubmittalID, Submittals.Created AS DateFiled, " +
"CheckDetails.Status AS CheckStatus, CheckDetails.CheckNumber, CheckDetails.DateWritten, CheckDetails.FaceAmount, CheckDetails.Reference, CheckDetails.ExhibitNo AS ExhibitNumber, " +
"CheckWriterDetails.FirstName, CheckWriterDetails.LastName " +
"FROM Submittals " +
"INNER JOIN LocationAccepted ON Submittals.LocationAcceptedID = LocationAccepted.LocationAcceptedID " +
"INNER JOIN CheckDetails ON LocationAccepted.LocationAcceptedID = CheckDetails.LocationAcceptedID AND Submittals.SubmittalID = CheckDetails.SubmittalID " +
"INNER JOIN CheckWriterDetails ON CheckDetails.CheckWriterID = CheckWriterDetails.CheckWriterID " +
"WHERE (CheckDetails.DateWritten >= {0})" +
"ORDER BY Submittals.Created DESC, Submittals.SubmittalID, CheckDetails.CheckDetailsID ";
return ExecuteQuery<SubmittalDetails>(sqlTxt, minDate);
}
}
public class SubmittalDetails
{
public int SubmittalID { get; set; }
public string Created { get; set; }
public int LocationAccepted { get; set; }
}
答案 0 :(得分:0)
编译器无法找到分部类的另一半,因此无法看到它是一个DataContext。
检查自动生成的文件MerchantsAppDataContext.designer.cs
里面定义了部分类MerchantsAppDataContext
的命名空间,并确保在代码中使用相同的命名空间。
namespace ??? // TODO: Use the same namespace as MerchantsAppDataContext.designer.cs
{
public partial class MerchantsAppDataContext
{
public IEnumerable<SubmittalDetails> GetSubmittalDetails(string minDate)
{
...
}
}
}