tags:

views:

29

answers:

1

I have followed this tutorial by Scott pretty much to the T against my own database.

http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx

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; }

}
A: 

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 class MerchantsAppDataContext is defined inside, and make sure you use the same namespace in your code.

namespace ??? // TODO: Use the same namespace as MerchantsAppDataContext.designer.cs
{
    public partial class MerchantsAppDataContext
    {
        public IEnumerable<SubmittalDetails> GetSubmittalDetails(string minDate)
        {
            ...
        }
    }
}
Mark Byers
Thanks Mark, That fixed it...
JBeckton