Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. public class Gig
  2. {
  3. public int Id { get; set; }
  4. public string Name { get; set; }
  5. public string ArtistId { get; set; }
  6. public string Venue { get; set; }
  7. public DateTime DateTime { get; set; }
  8. public int GenreId { get; set; }
  9. public bool IsCanceled { get; set; }
  10.  
  11. // Navigation property here
  12. public virtual Genre Genre { get; set; }
  13. public virtual ApplicationUser Artist { get; set; }
  14. }
  15.  
  16. public class Genre
  17. {
  18. public int Id { get; set; }
  19. public string Name { get; set; }
  20. }
  21.  
  22. public class ApplicationUser : IdentityUser
  23. {
  24. public string Name { get; set; }
  25. }
  26.  
  27. var gigs = db.Gigs
  28. // Iam eager loading property here
  29. .Include(g => g.Artist)
  30. .Include(g => g.Genre)
  31. .Where(g => g.DateTime > DateTime.Now && !g.IsCanceled)
  32. .GroupBy(x=>x.DateTime.Month).OrderBy(x=>x.Key);
  33.  
  34. var gigs = db.Gigs
  35. //I can get Artist and Genre data
  36. .Include(g => g.Artist)
  37. .Include(g => g.Genre)
  38. .Where(g => g.DateTime > DateTime.Now && !g.IsCanceled)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement