Skip to content

Instantly share code, notes, and snippets.

@mr5z
Last active October 29, 2020 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mr5z/f95e56cc91690bee4c14a4323b64c0d2 to your computer and use it in GitHub Desktop.
Save mr5z/f95e56cc91690bee4c14a4323b64c0d2 to your computer and use it in GitHub Desktop.
Convert loop in a single query
foreach(var entry in caveQuery)
{
var pointQuery =
from path in context.Path
join cave in context.Cave on path.CaveId equals cave.Id
join point in context.Point on path.Id equals point.PathId
where cave.Id == entry.Id
select new PointDto
{
X = point.X,
Y = point.Y,
Dx = point.Dx,
Dy = point.Dy
};
entry.Path.Points = pointQuery.ToList();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment