2017-01-05 3 views
0

Ich mag die folgende SQL-Abfrage in seiner LINQ zu Entity-Version konvertieren:LINQ to Entities - Wie SQL-Abfrage konvertieren (UnionAggregate) in 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

Siehe Msdn: https://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b – jdweng

+0

@FakeisMe Was ich versuche zu tun ist das UnionAggregate von SqlGeometries nicht die Union der Raws, danke. – antobonfiglio

Antwort

0

In LINQ Vereinigung all funktionalen zur Verfügung gestellt von Collection.Concat() Methode.

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));