开发者

Linq to Sql with Stored Procedure

I am trying to use stored procedure in dbml, but I get below error. The Stored procedure h开发者_如何学Goas multiple join tables, but it returns a row.

public static List<SP_EMP_MASTER_DETAILResult> GetEmployeeDetail(string userName, string userLocation)
{
    var query = (from q in db.SP_EMP_MASTER_DETAIL(userLocation, userName)
                 select new SP_EMP_MASTER_DETAILResult { ID = q.EMP_ID, Name = q.EMP_NM }).ToList();
    return query;
}

This is an error.

An object reference is required for the non-static field, method, or property 'Tiger.Models.HomeRepository.db'


Your method is static... IS your db variable static also? You can't reference a non-static class member in your static method.....

Static methods and properties cannot access non-static fields and events in their containing type, and they cannot access an instance variable of any object unless it is explicitly passed in a method parameter.

from http://msdn.microsoft.com/en-us/library/79b3xss3.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜