from..select linq クエリを使用して XML ファイルからデータを読み取っていますが、データが膨大です。私が読み取ることができるデータの最大セットは 1100 行で、各行は数百文字で構成されています。これにより、電話がハングし、アプリケーションがクラッシュします。エミュレーターでは、ロードにかなりの時間がかかりますが、正常に動作します。
今私が欲しいのは、クエリにデータ要素を含めたいいくつかの条件に基づいています。例として、私が今持っているものは...
var dataSet = from r in something.Elements("chapter")
select new dictChapter{
Name = r.Attribute("Name").Value,
Desc1 = r.Attribute("Description1").Value,
Desc2 = r.Attribute("Description2").Value,
Desc3 = r.Attribute("Description3").Value
};
ListBox.DataContext = dataSet;
しかし、設定に基づいて説明を選択したいと思います。次のようなものが欲しい(うまくいかないことはわかっているが、やりたいことを説明したい)
var dataSet = from r in something.Elements("chapter")
select new dictChapter{
Name = r.Attribute("Name").Value,
if (ShowDesc1 == true)
Desc1 = r.Attribute("Description1").Value,
if (ShowDesc2 == true)
Desc2 = r.Attribute("Description2").Value,
if (ShowDesc3 == true)
Desc3 = r.Attribute("Description3").Value
};
ListBox.DataContext = dataSet;
- Cシャープでこれを達成するにはどうすればよいですか?
- 私の問題に対するより良い解決策はありますか?
どうもありがとう