私はかなり単純なLinqクエリ(簡略化されたコード)を持っています:
dim x = From Product In lstProductList.AsParallel
Order By Product.Price.GrossPrice Descending Select Product
製品はクラスです。Product.Price は子クラスで、GrossPrice はそのプロパティの 1 つです。価格を計算するには、Session("exchange_rate") を使用する必要があります。
したがって、lstProductList の各アイテムには、次のことを行う関数があります。
NetPrice=NetPrice * Session("exchange_rate")
(そして GrossPrice は NetPrice+VatAmount を返します)
何を試しても、セッション状態にアクセスできません。
HttpContext.Current を試しましたが、何も返されません。クラスでIRequiresSessionStateの実装を試しました(これは、一般的なhttpハンドラー[.ashx]で同様の状況に役立ちます)-運が悪いです。
シンプルな InProc セッション状態モードを使用しています。為替レートはユーザー固有のものでなければなりません。
私に何ができる?
私が働いている: Web 開発、.Net 4、VB.net
ステップバイステップ:
page_load (.aspx 内)
dim objSearch as new SearchClass()
dim output = objSearch.renderProductsFound()
その後、objSearch.renderProductsFound:
lstProductList.Add(objProduct(1))
...
lstProductList.Add(objProduct(n))
dim x = From Product In lstProductList.AsParallel
Order By Product.Price.GrossPrice 降順 製品を選択
In Product.Price.GrossPrice Get :
return me.NetPrice+me.VatAmount
Product.Price.NetPrice Get:
return NetBasePrice*Session("exchange_rate")
繰り返しますが、単純化されたコードで、ここに貼り付けるには多すぎます。クエリを For ループにアンラップすると、正常に動作します。