0
私は以下の関数+コードを解析してWebサービスのリクエストをクエリし、理論的にはアプリケーションに結果を格納します(1日に1回リフレッシュするだけで済みます。アプリケーションが更新されます)。LINQ/HttpContext.Application&WebServicesを扱う
//tocommondata is a reference to the common stuff in the webservice
var dCountries = toCommonData.PropertyCountries; //KeyValuePair
var dRegions = toCommonData.Regions;//Array
var dAreas = toCommonData.Areas;//Array
var commonDAT = (from c in dCountries
join r in dRegions on c.Key equals r.CountryCode
join a in dAreas on r.Id equals a.RegionId
join p in dResorts on a.Id equals p.AreaId
select new CommonSave
{
Key = c.Key,
Value = c.Value,
Id = r.Id,
Name = r.Name,
dAreasID = a.Id,
dAreasName = a.Name,
}
).ToList().AsQueryable();
HttpContext.Current.Application["commonDAT"] = commonDAT;
このビットは、ファイン
foreach (var item in commonDAT)
{
Response.Write(item.value);
}
ワークス**理想的には私は(私は、私は様々な試したされたデータにアクセスできるようにし、その後appmemoryから引き出したいですおそらく愚かな)情報を使用する方法。ちょうど私の問題を引き起こしていることを引き出し:マークとしてO(**
//This Seems to kinda work for at least grabbing it (I'm probably doing this REALLY wrong).
IQueryable appCommonRar = (IQueryable)HttpContext.Current.Application["commonDAT"];
回答(.AsQueryable()) クイック例
を削除これを冗長な答えにするには、結果セットを再クエリして表示するための素早い方法...
List<CommonSave> appcommon = (List<CommonSave>)HttpContext.Current.Application["commonDAT"];
Response.Write(appcommon.Count()); // Number of responses
var texst = (from xs in appcommon
where xs.Key == "GBR"
select xs.dAreasName
);
foreach (var item in texst)
{
Response.Write("<br><b>"+item.ToString()+"<b><br>");
}
うまくいけば誰かに利用してください。
リスト appcommon =(リスト)HttpContext.Current.Application ["commonRAR"]; - エラーがレンダリングされません。 - 'System.Collections.Generic.List'1 [WebServiceTEST.CommonSave]'と入力すると、 'System.Linq.EnumerableQuery'1 [WebServiceTEST.CommonSave]'オブジェクトをキャストできません。 。 - –
私は(私は取得していないappmemで一度リストにアクセスするためのクラスとの作業は、(http://stackoverflow.com/questions/73542/ilistt-to-iqueryablet) ... –
私はリストとして残しておいた。あなたは(linq).ToList()を持っています。ToQuery()。ちょうど(linq).ToList()のままにしておきます。 –