2010年11月1日 星期一

VS2010 LINQ Stored Procedure

更新某支Stored Procedure, 開啟dbml檔刪除SP,, Server Explore連上DB後,直接拖拉新的SP,
出現這個訊息
The return types for the following stored procedures could not be detected. Set the return type for each stored procedure in the Properties window.

參考這篇...

Error: Unknown Return Type, The return types for the following stored procedures could not be detected….(LINQ).


建議的二種方法都不喜歡.

最後只好手動修改dbml檔的 .designer.cs檔

原本wizard自已產出的code如下
[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.zspTest")]
        public void zspTest([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="SmallInt")] System.Nullable<short> param1,
            [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="SmallInt")] System.Nullable<short> param2,
            [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] ref System.Nullable<int> rtn)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), param1, param2, rtn);
            rtn = ((System.Nullable<int>)(result.GetParameterValue(2)));
        }

手動改成

[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.zspTest")]
        public int zspTest([global::System.Data.Linq.Mapping.ParameterAttribute(DbType="SmallInt")] System.Nullable<short> param1,
            [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="SmallInt")] System.Nullable<short> param2,
            [global::System.Data.Linq.Mapping.ParameterAttribute(DbType="Int")] ref System.Nullable<int> rtn)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), param1, param2, rtn);
            rtn = ((System.Nullable<int>)(result.GetParameterValue(2)));
            return ((int)(result.ReturnValue));
        }

沒有留言:

張貼留言

publish error allowDefinition='MachineToApplication'

一個老舊的aspx web form專案,調了一些功能建置成功,但進行部署時顯示以下錯誤。 在應用程式層級之外使用註冊為 allowDefinition='MachineToApplication' 的區段發生錯誤。錯誤的原因可能是虛擬目錄尚未在 IIS 中設定為...