-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #28633
- Loading branch information
Showing
8 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/libraries/System.Data.Common/src/System/Data/Common/DbBatch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace System.Data.Common | ||
{ | ||
public abstract class DbBatch : IDisposable, IAsyncDisposable | ||
{ | ||
public DbBatchCommandCollection BatchCommands => DbBatchCommands; | ||
|
||
protected abstract DbBatchCommandCollection DbBatchCommands { get; } | ||
|
||
public abstract int Timeout { get; set; } | ||
|
||
public DbConnection? Connection | ||
{ | ||
get => DbConnection; | ||
set => DbConnection = value; | ||
} | ||
|
||
protected abstract DbConnection? DbConnection { get; set; } | ||
|
||
public DbTransaction? Transaction | ||
{ | ||
get => DbTransaction; | ||
set => DbTransaction = value; | ||
} | ||
|
||
protected abstract DbTransaction? DbTransaction { get; set; } | ||
|
||
public DbDataReader ExecuteReader(CommandBehavior behavior = CommandBehavior.Default) | ||
=> ExecuteDbDataReader(behavior); | ||
|
||
protected abstract DbDataReader ExecuteDbDataReader(CommandBehavior behavior); | ||
|
||
public Task<DbDataReader> ExecuteReaderAsync(CancellationToken cancellationToken = default) | ||
=> ExecuteDbDataReaderAsync(CommandBehavior.Default, cancellationToken); | ||
|
||
public Task<DbDataReader> ExecuteReaderAsync( | ||
CommandBehavior behavior, | ||
CancellationToken cancellationToken = default) | ||
=> ExecuteDbDataReaderAsync(behavior, cancellationToken); | ||
|
||
protected abstract Task<DbDataReader> ExecuteDbDataReaderAsync( | ||
CommandBehavior behavior, | ||
CancellationToken cancellationToken); | ||
|
||
public abstract int ExecuteNonQuery(); | ||
|
||
public abstract Task<int> ExecuteNonQueryAsync(CancellationToken cancellationToken = default); | ||
|
||
public abstract object? ExecuteScalar(); | ||
|
||
public abstract Task<object?> ExecuteScalarAsync(CancellationToken cancellationToken = default); | ||
|
||
public abstract void Prepare(); | ||
|
||
public abstract Task PrepareAsync(CancellationToken cancellationToken = default); | ||
|
||
public abstract void Cancel(); | ||
|
||
public DbBatchCommand CreateBatchCommand() => CreateDbBatchCommand(); | ||
|
||
protected abstract DbBatchCommand CreateDbBatchCommand(); | ||
|
||
public virtual void Dispose() {} | ||
|
||
public virtual ValueTask DisposeAsync() | ||
{ | ||
Dispose(); | ||
return default; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/libraries/System.Data.Common/src/System/Data/Common/DbBatchCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.ComponentModel; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace System.Data.Common | ||
{ | ||
public abstract class DbBatchCommand | ||
{ | ||
public abstract string CommandText { get; set; } | ||
|
||
public abstract CommandType CommandType { get; set; } | ||
|
||
public abstract int RecordsAffected { get; } | ||
|
||
public DbParameterCollection Parameters => DbParameterCollection; | ||
|
||
protected abstract DbParameterCollection DbParameterCollection { get; } | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/libraries/System.Data.Common/src/System/Data/Common/DbBatchCommandCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
namespace System.Data.Common | ||
{ | ||
public abstract class DbBatchCommandCollection : IList<DbBatchCommand> | ||
{ | ||
public abstract IEnumerator<DbBatchCommand> GetEnumerator(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
|
||
public abstract void Add(DbBatchCommand item); | ||
|
||
public abstract void Clear(); | ||
|
||
public abstract bool Contains(DbBatchCommand item); | ||
|
||
public abstract void CopyTo(DbBatchCommand[] array, int arrayIndex); | ||
|
||
public abstract bool Remove(DbBatchCommand item); | ||
|
||
public abstract int Count { get; } | ||
|
||
public abstract bool IsReadOnly { get; } | ||
|
||
public abstract int IndexOf(DbBatchCommand item); | ||
|
||
public abstract void Insert(int index, DbBatchCommand item); | ||
|
||
public abstract void RemoveAt(int index); | ||
|
||
public abstract DbBatchCommand this[int index] { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters