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

沒有留言:

張貼留言

pdf.js 無法顯示部份字

有個檔案在pdf viewer套件中無法顯示內容,但下載檔案後使用工具又可以正常顯示。 本來以為是套件版本太舊的原因,於是去下載pdf viewer套件 https://github.com/mozilla/pdf.js 更新後還是一樣。 覺得應是字型缺漏的問題,於是用PDF-X...