Skip to content

Commit cec198e

Browse files
authored
API fix to System.Data batching API (#56525)
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
1 parent e3a45f7 commit cec198e

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/libraries/System.Data.Common/ref/System.Data.Common.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1945,10 +1945,10 @@ public abstract class DbBatch : System.IDisposable, System.IAsyncDisposable
19451945
public abstract class DbBatchCommand
19461946
{
19471947
public abstract string CommandText { get; set; }
1948-
public abstract CommandType CommandType { get; set; }
1948+
public abstract System.Data.CommandType CommandType { get; set; }
19491949
public abstract int RecordsAffected { get; }
1950-
public DbParameterCollection Parameters { get { throw null; } }
1951-
protected abstract DbParameterCollection DbParameterCollection { get; }
1950+
public System.Data.Common.DbParameterCollection Parameters { get { throw null; } }
1951+
protected abstract System.Data.Common.DbParameterCollection DbParameterCollection { get; }
19521952
}
19531953
public abstract class DbBatchCommandCollection : System.Collections.Generic.IList<DbBatchCommand>
19541954
{
@@ -1964,7 +1964,9 @@ public abstract class DbBatchCommandCollection : System.Collections.Generic.ILis
19641964
public abstract int IndexOf(DbBatchCommand item);
19651965
public abstract void Insert(int index, DbBatchCommand item);
19661966
public abstract void RemoveAt(int index);
1967-
public abstract DbBatchCommand this[int index] { get; set; }
1967+
public System.Data.Common.DbBatchCommand this[int index] { get { throw null; } set { throw null; } }
1968+
protected abstract System.Data.Common.DbBatchCommand GetBatchCommand(int index);
1969+
protected abstract void SetBatchCommand(int index, System.Data.Common.DbBatchCommand batchCommand);
19681970
}
19691971
public abstract partial class DbColumn
19701972
{

src/libraries/System.Data.Common/src/System/Data/Common/DbBatchCommandCollection.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public abstract class DbBatchCommandCollection : IList<DbBatchCommand>
3232

3333
public abstract void RemoveAt(int index);
3434

35-
public abstract DbBatchCommand this[int index] { get; set; }
35+
public DbBatchCommand this[int index]
36+
{
37+
get => GetBatchCommand(index);
38+
set => SetBatchCommand(index, value);
39+
}
40+
41+
protected abstract DbBatchCommand GetBatchCommand(int index);
42+
43+
protected abstract void SetBatchCommand(int index, DbBatchCommand batchCommand);
3644
}
3745
}

0 commit comments

Comments
 (0)