The function in dbml is,
[Function(Name = "dbo.sp_GetQuestions")]
public ISingleResult<vw_QuestionMaster> sp_GetQuestions([Parameter(Name = "Sort", DbType = "Int")] System.Nullable<int> sort, [Parameter(Name = "Title", DbType = "VarChar(50)")] string title, [Parameter(Name = "Tags", DbType = "VarChar(50)")] string tags, [Parameter(Name = "RecordFrom", DbType = "Int")] System.Nullable<int> recordFrom, [Parameter(Name = "RecordTo", DbType = "Int")] System.Nullable<int> recordTo)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), sort, title, tags, recordFrom, recordTo);
return ((ISingleResult<vw_QuestionMaster>)(result.ReturnValue));
}
The function that I defined in DataAccessLayer is,
public static ?????????????????? GetMostDiscussedQuestions()
{
using (AbToBolDataClassesDataContext db = new AbToBolDataClassesDataContext())
{
//ISingleResult<vw_QuestionMaster> questions = db.sp_GetQuestions(1, null, null, 1, 5);
//return questions.ToList();
var query = from qm in db.sp_GetQuestions(1, null, null, 1, 5)
select qm;
return query;
}
}
Here in this case, i am calling the above method to set the datasource of a gridview. Although i am getting data in query by calling the stored procedure, but please aware me about what should be the correct return type for this method. and how to fetch the same from 'query'.
I tried out with, query.ToList() but is throwing error of non-conversion of List<> type to DataTable.