title: How do I delete multiple rows in Entity Framework (without foreach)
body: <p>I'm deleting several items from a table using Entity Framework. There isn't a foreign key / parent object so I can't handle this with OnDeleteCascade.</p>
  
  <p>Right now I'm doing this:</p>
  
  <pre><code>var widgets = context.Widgets
      .Where(w =&gt; w.WidgetId == widgetId);
  
  foreach (Widget widget in widgets)
  {
      context.Widgets.DeleteObject(widget);
  }
  context.SaveChanges();
  </code></pre>
  
  <p>It works but the foreach bugs me. I'm using EF4 but I don't want to execute SQL. I just want to make sure I'm not missing anything - this is as good as it gets, right? I can abstract it with an extension method or helper, but somewhere we're still going to be doing a foreach, right?</p>