【问题标题】:How to stop LINQ to SQL stored procedure wiring code from being automatically generated?如何阻止自动生成 LINQ to SQL 存储过程接线代码?
【发布时间】:2012-10-17 09:06:09
【问题描述】:

我有一个用于返回 IMultipleResult 在部分类中实现的存储过程的 LINQ to SQL 接线代码。

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));
        }


    }
}

【问题讨论】:

    标签: linq-to-sql


    【解决方案1】:

    我删除了 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));
            }
    
    
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-25
      • 2012-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多