次の形式の Linq to Entities クエリがあります。
var x = from a in SomeData
where ... some conditions ...
select new MyType
{
Property = a.Property,
ChildCollection = from b in a.Children
select new MyChildType
{
SomeProperty = b.Property,
AnotherProperty = b.AnotherProperty
}
};
var y = from a in SomeData
where ... some other conditions ...
select new MyType
{
Property = a.Property,
ChildCollection = from b in a.Children
select new MyChildType
{
SomeProperty = b.Property,
AnotherProperty = b.AnotherProperty
}
};
var results = x.Concat(y);
(これは単純化された例です。'where' 句と 'select' 句は、ここに示されているよりも複雑です。単一の結合されたものを作成するのは複雑すぎて、条件が多すぎて時間がかかるため、個別のクエリ ステートメントを使用しています。コンパイル)
正常にコンパイルされますが、実行時に例外が発生して失敗します。
"The nested query is not supported. Operation1='UnionAll' Operation2='MultiStreamNest'
注、ネストされた型付き構造に投影しようとしています。Concat() の前に x と y で .ToList() を呼び出すと、正常に動作します。さらなるポイントとして、私のプロパティの 1 つは列挙型ですが、整数ラッパー プロパティを使用してそれに割り当てています。
すべてのデータをメモリに取り込まずにやりたいことを実行できる方法はありますか? それとも列挙型が失敗の原因ですか?
ありがとう、
T