19. februar 2009 - 02:45Der er
4 kommentarer og 1 løsning
vb.net til c# Linq 2
Nogle der kan oversætte denne til c#?
Dim doc = XDocument.Load(file) Dim q = _ From v In doc.<File>.<Region>.<Polygon>.<Vertex> _ Let _ Polygon = v.Parent, _ Region = v.Parent.Parent _ Group By _ Polygon, _ Region _ Into _ Group, _ MinX = MinDBL(v.@X), _ MinY = MinDBL(v.@Y), _ MaxX = MaxDBL(v.@X), _ MaxY = MaxDBL(v.@Y) _ Select _ TheMapPolygon = (From tmp In Group Select tmp.v).ToMapPolygon(), _ Region, _ BoundingBox = New Rect(New Point(MinX, MinY), New Point(MaxX, MaxY)) _ Group By _ Region _ Into _ Group, _ BoundingBox = Enclose(BoundingBox) _ Select _ Region = New MapRegion(Region.@Name, (From item In Group Select item.TheMapPolygon), (From f In Region...<FipsCode> Select CInt(f.Value)), BoundingBox)
den går gal ved group by, debuggeren har svært ved at komme med præcise info ved en så lang LIQ statement.
var doc = XDocument.Load(file); var q = from v in doc.Element("File").Elements("Region").Elements("Polygon").Elements("Vertex") let Polygon = v.Parent let Region = v.Parent.Parent select new {Polygon, Region } group v by Polygon, Region into g, MinX = MinDBL(v.@X), MinY = MinDBL(v.@Y), MaxX = MaxDBL(v.@X), MaxY = MaxDBL(v.@Y) select _ TheMapPolygon = (from tmp in g select tmp.v).ToMapPolygon(), Region, BoundingBox = new Rect(new Point(MinX, MinY), new Point(MaxX, MaxY)) group by Region into _ Group, BoundingBox = Enclose(BoundingBox) select Region = new MapRegion(Region.@Name, (from item in Group select item.TheMapPolygon), (from f in Region...<FipsCode> Select CInt(f.Value)), BoundingBox)
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.