如何自动生成LINQ to SQL存储过程接线代码?

时间:2012-10-17 09:06:09

标签: linq-to-sql

我有一个存储过程的LINQ to SQL连接代码,它返回在部分类中实现的IMultipleResult

dbml文件中添加新对象时,会再次生成存储过程接线代码;这会导致代码同时出现在我的部分类和designer.cs中。

如何标记存储过程,以便通过在dbml设计器中进行更改来自动生成接线代码?

namespace Audit
{
    public partial class LinqAuditDataContext 
    {
        [Function(Name = "getRows")]
        [ResultType(typeof(featuresE))]
        [ResultType(typeof(featuresWater))]
        [ResultType(typeof(featuresV))]
        public IMultipleResults getRows([global::System.Data.Linq.Mapping.ParameterAttribute(DbType = "Int")] System.Nullable<int> page, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType = "Int")] System.Nullable<int> rowsshow, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType = "NVarChar(30)")] string table, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType = "Bit")] System.Nullable<bool> fact, [global::System.Data.Linq.Mapping.ParameterAttribute(DbType = "Int")] System.Nullable<int> id_obj)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), page, rowsshow, table, fact, id_obj);
            return ((IMultipleResults)(result.ReturnValue));
        }


    }
}

1 个答案:

答案 0 :(得分:0)

我删除了dbml文件中的getrows,并在部分类的不同文件中定义。 有用 ... 也许有个主意?

部分LinqAuditDataContext中的函数

public partial class LinqAuditDataContext 
    {
        [Function(Name = "getRows")]
        [ResultType(typeof(featuresE))]
        [ResultType(typeof(featuresWater))]
        [ResultType(typeof(featuresV))]
        public   IMultipleResults getRows(System.Nullable<int> page,  System.Nullable<int> rowsshow, 
            string table, System.Nullable<bool> fact, 
            System.Nullable<int> id_obj, bool t)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), page, rowsshow, table, fact, id_obj);
            return ((IMultipleResults)(result.ReturnValue));
        }


    }