1

DBML デザイナーでのコード


[global::System.Data.Linq.Mapping.FunctionAttribute(Name="dbo.uspCalculateRiskMatrix")]   
      public int uspCalculateRiskMatrix([global::System.Data.Linq.Mapping.ParameterAttribute(Name="CashPrice", DbType="Float")] System.Nullable cashPrice,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="InputAPH", DbType="Int")] System.Nullable inputAPH,    [global::System.Data.Linq.Mapping.ParameterAttribute(Name="Bushels", DbType="Int")] System.Nullable bushels,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="PercentageCover", DbType="Float")] System.Nullable percentageCover,    [global::System.Data.Linq.Mapping.ParameterAttribute(Name="BasicEstimate", DbType="Float")] System.Nullable basicEstimate,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="CallStrike", DbType="Float")] System.Nullable callStrike,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="CallBu", DbType="Int")] System.Nullable callBu,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="CallPremium", DbType="Float")] System.Nullable callPremium,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="PutStrike", DbType="Float")] System.Nullable putStrike,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="PutBu", DbType="Int")] System.Nullable putBu,    [global::System.Data.Linq.Mapping.ParameterAttribute(Name="PutPremium", DbType="Float")] System.Nullable putPremium,    [global::System.Data.Linq.Mapping.ParameterAttribute(Name="TotalAcres", DbType="Float")] System.Nullable totalAcres,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="AvgPrice", DbType="Float")] System.Nullable avgPrice,     [global::System.Data.Linq.Mapping.ParameterAttribute(Name="PerAcreProductionCost",     DbType="Float")] System.Nullable perAcreProductionCost,    [global::System.Data.Linq.Mapping.ParameterAttribute(Name="SpringPrice", DbType="Float")] System.Nullable springPrice)   
      {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), cashPrice, inputAPH, bushels, percentageCover, basicEstimate, callStrike, callBu, callPremium, putStrike, putBu, putPremium, totalAcres, avgPrice, perAcreProductionCost, springPrice);
            return ((int)(result.ReturnValue));
      }

================================================== =======================

SPをgridviewにバインドする私のコード


 var a = from risk in HRM_dc.uspCalculateRiskMatrix(CashPrice, InputAPH, Bushels, PercentageCover, BasicEstimate, CallStrike, CallBu, CallPremium,
                                                                 PutStrike, PutBu, PutPremium, TotalAcres, AvgPrice, PerAcreProductionCost, SpringPrice)
                        select risk;

                GridView gvRisk = new GridView();
                gvRisk.DataSource = a;
                gvRisk.DataBind(); 

エラー: エラー 2 ソース タイプ 'int' のクエリ パターンの実装が見つかりませんでした。「選択」が見つかりません。

高速TIAを助けてください

4

1 に答える 1

0

この種のエラー (クエリ パターンが見つかりません) は通常、名前空間が不足している場合、またはソース オブジェクトが IEnumerable を実装していない場合に発生します。

ストアド プロシージャの戻り値の型を確認してください。これは型であり、コレクション型でもInteger実装されていません。IEnumerable<T>整数の配列を使用する場合int[] intArray = {10, 20};は、linq を使用できます。

このように実装することはできません。さらに、Gridview のDataSourceプロパティは、そのようなタイプのデータを表示することをサポートしていません。

参照:
クエリ パターンの実装が
見つかりませんでした Linq エラー「ソース タイプ 'System.Linq.IQueryable' Join Not Found' のクエリ パターンの実装が見つかりませんでした」

編集:コメントによると:これを確認してくださいAccessing dynamic created stored procedure from LINQ、それがあなたの解決策かもしれません..

于 2012-05-10T13:46:07.213 に答える