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

沒有留言:

張貼留言

IIS 網站無法下載中文檔名檔案因為取消高位元字元

 網址+中文檔案名稱方式下載檔案顯示 404 - 找不到檔案或目錄。 但英數字檔案名稱則可下載。 因為設定GCB IIS,其中1項 將高位元字元預設取消勾選了。 27 TWGCB-04-014-0028 要求篩選與其他限制模組 允許高位元字元 這項原則設定決定查詢...