我从数据库中获取一堆时间表条目并使用它们创建发票。一旦我保存了发票并拥有一个Id,我想使用发票Id更新时间表条目。有没有一种批量更新实体而无需逐个加载它们的方法?
void SaveInvoice(Invoice invoice, int[] timeEntryIds) {
context.Invoices.Add(invoice);
context.SaveChanges();
// Is there anything like?
context.TimeEntries
.Where(te => timeEntryIds.Contains(te.Id))
.Update(te => te.InvoiceId = invoice.Id);
}