PrepAway - Latest Free Exam Questions & Answers

Which code segment should you use?

The database contains orphaned Color records that are no longer connected to Part records.
You need to clean up the orphaned records. You have an existing ContosoEntities context object named context.
Which code segment should you use?

PrepAway - Latest Free Exam Questions & Answers

A.
var unusedColors = context.Colors.Where(c => !c.Parts.Any()).ToList();
foreach (var unused in unusedColors){
context.DeleteObject(unused)
}
context.SaveChanges();

B.
context.Colors.TakeWhile(c => !c.Parts.Any());
context.SaveChanges();

C.
context.Colors.ToList().RemoveAll(c => !c.Parts.Any());
context.SaveChanges();

D.
var unusedColors = context.Colors.Where(c => !c.Parts.Any());
context.DeleteObject(unusedColors);
context.SaveChanges();


Leave a Reply