I have followed this tutorial by Scott pretty much to the T against my own database.
I am getting an error in my Partial class.
The name 'ExecuteQuery' does not exist in the current context. I cannot for the life of me figure out what went wrong.
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; }
}
The compiler is unable to find the other half of the partial class, and so it can't see that it is a DataContext.
Check the auto-generated file
MerchantsAppDataContext.designer.cs
to which namespace the partial classMerchantsAppDataContext
is defined inside, and make sure you use the same namespace in your code.