示例#1
0
        private async Task CommitChangesAddedItemsAsync(HashSet <T> items, bool useAsync)
        {
            if (items?.Count > 0)
            {
                GenerateCustomPrimaryKeys(items);
                bool hasIdentity = CheckIfCanUseIdentityPrimaryKey();

                using (DbCommand command = _commandGenerator.GetInsertCommand())
                {
                    PrepareCommand(command);
                    foreach (T item in items)
                    {
                        _commandGenerator.FillCommand(command, item);
                        if (hasIdentity)
                        {
                            var id = await ExecuteScalarAsync(command, useAsync);

                            _tableInfo.IdentityPrimaryKey.SetValue(item, id);
                        }
                        else
                        {
                            await ExecuteNonQueryAsync(command, useAsync);
                        }
                    }
                }
            }
        }
示例#2
0
 private void CommitChangesAddedItems(HashSet <T> items)
 {
     GeneratePrimaryKeys(items);
     using (DbCommand command = _commandGenerator.GetInsertCommand())
     {
         foreach (T item in items)
         {
             _commandGenerator.FillCommand(command, item);
             _provider.ExecuteNonQueryCommand(command);
         }
     }
 }
示例#3
0
 private async Task CommitChangesAddedItemsAsync(HashSet <T> items, bool useAsync)
 {
     if (items?.Count > 0)
     {
         GeneratePrimaryKeys(items);
         using (DbCommand command = _commandGenerator.GetInsertCommand())
         {
             PrepareCommand(command);
             foreach (T item in items)
             {
                 _commandGenerator.FillCommand(command, item);
                 await ExecuteNonQueryAsync(command, useAsync);
             }
         }
     }
 }