Skip to content

Instantly share code, notes, and snippets.

@StefanRiedmann
Created May 7, 2020 01:44
Show Gist options
  • Save StefanRiedmann/f34fd002b5bca2716fea3d4f38960e47 to your computer and use it in GitHub Desktop.
Save StefanRiedmann/f34fd002b5bca2716fea3d4f38960e47 to your computer and use it in GitHub Desktop.
Read and print Garden summaries for a list of years.
public static void ReadGardenInfos(GardenContext db, params int[] years)
{
var gardenInfos = db.GardenInfos.AsNoTracking()
.Include(gi => gi.Garden)
.Where(gi => years.Contains(gi.Year))
.OrderBy(gi => gi.Garden.Name).ThenBy(gi => gi.Year)
.ToList();
gardenInfos.ForEach(info => Console.WriteLine($"Crops in '{info.Garden.Name}' ({info.Year}): {info.AllGardenCrops}"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment