2017-01-05 6 views
0

にSQLクエリ(UnionAggregate)を変換するにはどうすればそのLINQエンティティのバージョンで次のSQLクエリを変換したい:Collection.Concatが提供するすべての機能LINQ組合でLINQは - LINQ

select 
geometry::UnionAggregate(geometries.GeometryBounds) 
from 
(select 
    GeometryBounds 
    from 
    Province where id in (1, 2) 
    union all 
    select 
    GeometryBounds 
    from 
    Region where id in (1, 2) 
    union all 
    select 
    GeometryBounds 
    from 
    Country where id in (1, 2) 
) as geometries 
+0

http://stackoverflow.com/questions/8394111/how-to-convert-sql-query-with-unions-to-linq – FakeisMe

+0

MSDNを参照してください。https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b – jdweng

+0

@FakeisMe私がしようとしているのは、SqlGeometriesのUnionAggregateが未加工組合ではなく、ありがとうございます。 – antobonfiglio

答えて

0

() 方法。

var ID = new[] {1, 2}; 

var query = (youContext.Province 
      .Select(x => x.GeometryBounds)) 
      .Concat 
      (youContext.Region 
      .Select(x => x.GeometryBounds)) 
      .Concat 
      (youContext.Country 
      .Select(x => x.GeometryBounds));