Which code segment should you use?
A. using (NorthwindDataContext dc = new NorthwindDataContext()){dc.ObjectTrackingEnabled = false;var categories = from c in dc.Categoriesselect c;foreach (var category in categories) {Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}}
B. using (NorthwindDataContext dc = new NorthwindDataContext()) {dc.DeferredLoadingEnabled = false;DataLoadOptions dlOptions = new DataLoadOptions();dlOptions.LoadWith<Category>(c => c.Products);dc.LoadOptions = dlOptions;var categories = from c in dc.Categoriesselect c;foreach (var category in categories){Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}}
C. using (NorthwindDataContext dc = new NorthwindDataContext()) {dc.DeferredLoadingEnabled = false;var categories = from c in dc.Categoriesselect c;foreach (var category in categories) {Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}}
D. using (NorthwindDataContext dc = new NorthwindDataContext()){dc.DeferredLoadingEnabled = false;DataLoadOptions dlOptions = new DataLoadOptions();dlOptions.AssociateWith<Category>(c => c.Products);dc.LoadOptions = dlOptions;var categories = from c in dc.Categoriesselect c;foreach (var category in categories){Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}}
Answer:B
Which code segment should you use?
A. using (NorthwindDataContext dc = new NorthwindDataContext()){dc.ObjectTrackingEnabled = false;var categories = from c in dc.Categoriesselect c;foreach (var category in categories) {Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}} B. using (NorthwindDataContext dc = new NorthwindDataContext()) {dc.DeferredLoadingEnabled = false;DataLoadOptions dlOptions = new DataLoadOptions();dlOptions.LoadWith<Category>(c => c.Products);dc.LoadOptions = dlOptions;var categories = from c in dc.Categoriesselect c;foreach (var category in categories){Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}} C. using (NorthwindDataContext dc = new NorthwindDataContext()) {dc.DeferredLoadingEnabled = false;var categories = from c in dc.Categoriesselect c;foreach (var category in categories) {Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}} D. using (NorthwindDataContext dc = new NorthwindDataContext()){dc.DeferredLoadingEnabled = false;DataLoadOptions dlOptions = new DataLoadOptions();dlOptions.AssociateWith<Category>(c => c.Products);dc.LoadOptions = dlOptions;var categories = from c in dc.Categoriesselect c;foreach (var category in categories){Console.WriteLine(“{0} has {1} products”, category.CategoryName, category.Products.Count);}}