Skip to content

Commit

Permalink
API fix to System.Data batching API
Browse files Browse the repository at this point in the history
Allow implementations of DbBatchCommandCollection to hide the indexer
with a narrower-typed version for their own implementation of
DbBatchCommand, as elsewhere in ADO.NET.

Fixup for #54467, part of #28633
  • Loading branch information
roji committed Jul 29, 2021
1 parent 742ea07 commit 1a0fa0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/libraries/System.Data.Common/ref/System.Data.Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1945,10 +1945,10 @@ public abstract class DbBatch : System.IDisposable, System.IAsyncDisposable
public abstract class DbBatchCommand
{
public abstract string CommandText { get; set; }
public abstract CommandType CommandType { get; set; }
public abstract System.Data.CommandType CommandType { get; set; }
public abstract int RecordsAffected { get; }
public DbParameterCollection Parameters { get { throw null; } }
protected abstract DbParameterCollection DbParameterCollection { get; }
public System.Data.Common.DbParameterCollection Parameters { get { throw null; } }
protected abstract System.Data.Common.DbParameterCollection DbParameterCollection { get; }
}
public abstract class DbBatchCommandCollection : System.Collections.Generic.IList<DbBatchCommand>
{
Expand All @@ -1964,7 +1964,9 @@ public abstract class DbBatchCommandCollection : System.Collections.Generic.ILis
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; }
public System.Data.Common.DbBatchCommand this[int index] { get { throw null; } set { throw null; } }
protected abstract System.Data.Common.DbBatchCommand GetBatchCommand(int index);
protected abstract void SetBatchCommand(int index, System.Data.Common.DbBatchCommand batchCommand);
}
public abstract partial class DbColumn
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public abstract class DbBatchCommandCollection : IList<DbBatchCommand>

public abstract void RemoveAt(int index);

public abstract DbBatchCommand this[int index] { get; set; }
public DbBatchCommand this[int index]
{
get => GetBatchCommand(index);
set => SetBatchCommand(index, value);
}

protected abstract DbBatchCommand GetBatchCommand(int index);

protected abstract void SetBatchCommand(int index, DbBatchCommand batchCommand);
}
}

0 comments on commit 1a0fa0e

Please sign in to comment.