public void BulkUpdate(Account account) { var accountEntity = Context.Accounts.SingleOrDefault(a => a.Name == account.Name); if (accountEntity == null) { var accountQuery = new AccountQuery(Context); account.Id = accountQuery.Create(account); } else { account.Id = accountEntity.Id; } foreach (var opportunity in account.Opportunities) { opportunity.AccountId = account.Id; BulkUpdate(opportunity); } }