Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. var countriesElse = db.Profiles
  2. .GroupBy(av => av.Country)
  3. .Select(g => new { Country = g.Key, Count = g.Count() });
  4. var otherCount = countriesElse
  5. .Where(x => x.Country != "US" && x.Country != "CA").FirstOrDefault();
  6.  
  7. ViewBag.otherCount = otherCount.Count;
  8.  
  9. if(otherCount != null)
  10. ViewBag.otherCount = otherCount.Count;
  11.  
  12. else ViewBag.otherCount = 0;
  13.  
  14. var profile = db.Profiles
  15. .GroupBy(av => av.Country)
  16. .Select(g => new { Country = g.Key, Count = g.Count() })
  17. .FirstOrDefault(x => x.Country != "US" && x.Country != "CA");
  18.  
  19. ViewBag.otherCount = profile== null ? 0 : profile.Count;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement