Linq操作存储过程,需要在继承DataContext的类中添加存储过程的执行函数

例如执行一个不带参数的存储过程,声明如下:

 [Function(Name = "GetMyInt")]
  public ISingleResult<MENU_TBL> GetInt()
  {
       IExecuteResult res = this.ExecuteMethodCall(this,((MethodInfo)MethodInfo.GetCurrentMethod()));
       return ((ISingleResult<MENU_TBL>)(res.ReturnValue));
  }

调用时候这样可以写

IList<MENU_TBL> t = dc.GetInt().ToList();

或者只返回一个

 var v = (from a in dc.GetInt()
            where a.MenuId==3
            select a.MName).First();

其中dc为DataContext对象或者其子类对象

如果在调用查询时候出现问题:无法枚举查询结果多次

可以看看上面标注红色的代码,因为返回结果是ISingleResult<T>类型

需要做个转换才能获得自己需要的结果。