练习扩展Linq to sql 生成的 datacontext 类
2010-08-31 22:53 音乐让我说 阅读(449) 评论(0) 编辑 收藏 举报
当我们写的存储过程过于复杂时,如果直接把它拖到Linq to sql 的可视化界面时,它显示的返回值是Int 类型,这是就需要我们自定义类来接收返回的记录行
代码如下:
using System.Data.Linq; using System.Data.Linq.Mapping; using System.Data; using System.Collections.Generic; using System.Reflection; using System.Linq; using System.Linq.Expressions; using System.ComponentModel; using System; namespace LinqDAL { public partial class CMSDataContext { /// <summary> /// 得到公司的评论 /// </summary> /// <param name="companyId">公司ID</param> /// <param name="beginNumber">分页的开始编号,最新值为1</param> /// <param name="endNumber">分页的结束编号,最新值为1</param> /// <param name="totalRecordCount">总评论数</param> /// <returns></returns> [Function(Name = "dbo.proc_GetSingleCompanyComment")] public IEnumerable<Company_CommentList> GetCommentByCompanyId([Parameter(DbType = "Int")] int companyId, [Parameter(DbType = "Int")] int beginNumber, [Parameter(DbType = "Int")] int endNumber, [Parameter(DbType = "Int")] ref int totalRecordCount) { IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), companyId, beginNumber, endNumber, totalRecordCount); totalRecordCount = ((int)(result.GetParameterValue(3))); /* 得到第4个参数的值 */ return ((IEnumerable<Company_CommentList>)(result.ReturnValue)); } } }
等待更新...
作者:音乐让我说(音乐让我说 - 博客园)
出处:http://music.cnblogs.com/
文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。