static void Main(string[] args) { var context = new AdsEntities(); var sw = new Stopwatch(); sw.Start(); AdsWithoutInclude(context); Console.WriteLine("Without Include: {0}", sw.Elapsed); sw.Restart(); AdsWithInclude(context); Console.WriteLine("With Include: {0}", sw.Elapsed); }
public static void AdsWithoutInclude(AdsEntities context) { var ads = context.Ads; string withoutInclude = ""; foreach (var ad in ads) { withoutInclude += string.Format("Ad Title: {0}, Ad Status: {1}, Ad Category: {2}, Ad Town: {3}, Ad User: {4}", ad.Title, ad.AdStatus.Status, (ad.Category == null ? "No Category" : ad.Category.Name), (ad.Town == null ? "No Town" : ad.Town.Name), ad.AspNetUser.Name); } }