'LINQ to SQL query containing joins resulting in class that contains arrays,
I'm currently working on a minecraft-like game. All-terrain data is stored in SQLite. I have 3 tables that should be joined by one SQL Query using LINQ to List theMother. Tables are:
public class Chunks {
[PrimaryKey]
public int Id { get; set; }
[Indexed]
public double X { get; set; }
[Indexed]
public double Y { get; set; }
public int Resolution { get; set; }
public float Size { get; set; }
public bool isBackground { get; set; }
}
public class Cell{
[PrimaryKey]
public int Id { get; set; }
public long GlobalX { get; set; }
public long GlobalZ { get; set; }
public long PivotX { get; set; }
public long PivotZ { get; set; }
public short Size { get; set; }
public double Random { get; set; }
public int ChunkPlotType { get; set; }
public bool isCommercial { get; set; }
public bool isFarming { get; set; }
public int BiomeType { get; set; }
public short Height { get; set; }
[Indexed]
public int ChunkOwnerId { get; set; }
}
public class Heightmap {//4225 rows for every chunk
[PrimaryKey]
public int Id { get; set; }
[Indexed]
public int ChunkOwnerId { get; set; }
public float Height { get; set; }
}
public class TheMotherOfAll {
public float CoordX;
public float coordY;
public Cell[] cells;
public float[] heightmap;
}
I think the final query should look like this:
public void Load(){
List<TheMotherOfAll> theMother = new List<TheMotherOfAll>(
from rowChunks in dbManager.Table<Chunks>()
join rowCells in dbManager.Table<Cell>()
where rowChunks.X > 100 && rowChunks.X < 200//for example
select rowChunks.X as theMother.CoordX, rowChunks.Y as theMother.CoordY
on rowChunks.id equals rowCells.ChunkOwnerId
//How to continue I don't know
)
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
