diff --git a/pkg/Microsoft.Private.PackageBaseline/packageIndex.json b/pkg/Microsoft.Private.PackageBaseline/packageIndex.json
index 6723f074967c..f9bd6629cf89 100644
--- a/pkg/Microsoft.Private.PackageBaseline/packageIndex.json
+++ b/pkg/Microsoft.Private.PackageBaseline/packageIndex.json
@@ -1143,7 +1143,7 @@
"4.1.0.0": "4.1.0",
"4.1.1.0": "4.3.0",
"4.2.0.0": "4.4.0",
- "4.2.1.0": "4.5.0"
+ "4.3.0.0": "4.5.0"
}
},
"System.Data.SqlXml": {
diff --git a/src/System.Data.SqlClient/dir.props b/src/System.Data.SqlClient/dir.props
index 4888b29a2299..a30234936837 100644
--- a/src/System.Data.SqlClient/dir.props
+++ b/src/System.Data.SqlClient/dir.props
@@ -2,7 +2,7 @@
- 4.2.1.0
+ 4.3.0.0
MSFT
\ No newline at end of file
diff --git a/src/System.Data.SqlClient/ref/System.Data.SqlClient.cs b/src/System.Data.SqlClient/ref/System.Data.SqlClient.cs
index 3071b6f05229..0f636b5134a8 100644
--- a/src/System.Data.SqlClient/ref/System.Data.SqlClient.cs
+++ b/src/System.Data.SqlClient/ref/System.Data.SqlClient.cs
@@ -184,6 +184,17 @@ public sealed partial class SqlMetaData
public static Microsoft.SqlServer.Server.SqlMetaData InferFromValue(object value, string name) { throw null; }
}
}
+namespace System.Data.Sql
+{
+ public sealed partial class SqlNotificationRequest
+ {
+ public SqlNotificationRequest() { }
+ public SqlNotificationRequest(string userData, string options, int timeout) { }
+ public string Options { get { throw null; } set { } }
+ public int Timeout { get { throw null; } set { } }
+ public string UserData { get { throw null; } set { } }
+ }
+}
namespace System.Data.SqlClient
{
public enum ApplicationIntent
@@ -331,6 +342,7 @@ public sealed partial class SqlCommand : System.Data.Common.DbCommand, System.IC
public System.Threading.Tasks.Task ExecuteXmlReaderAsync() { throw null; }
public System.Threading.Tasks.Task ExecuteXmlReaderAsync(System.Threading.CancellationToken cancellationToken) { throw null; }
public override void Prepare() { }
+ public System.Data.Sql.SqlNotificationRequest Notification { get { throw null; } set { } }
}
public sealed partial class SqlConnection : System.Data.Common.DbConnection, System.ICloneable
{
@@ -426,6 +438,70 @@ public sealed partial class SqlDataAdapter : System.Data.Common.DbDataAdapter, S
protected override void OnRowUpdating(System.Data.Common.RowUpdatingEventArgs value) { }
object System.ICloneable.Clone() { throw null; }
}
+ public sealed partial class SqlDependency
+ {
+ public SqlDependency() { }
+ public SqlDependency(SqlCommand command) { }
+ public SqlDependency(SqlCommand command, string options, int timeout) { }
+ public bool HasChanges { get { throw null; } }
+ public string Id { get { throw null; } }
+ public event OnChangeEventHandler OnChange { add { } remove { } }
+ public void AddCommandDependency(SqlCommand command) { }
+ public static bool Start(string connectionString) { throw null; }
+ public static bool Start(string connectionString, string queue) { throw null; }
+ public static bool Stop(string connectionString) { throw null; }
+ public static bool Stop(string connectionString, string queue) { throw null; }
+ }
+ public delegate void OnChangeEventHandler(object sender, SqlNotificationEventArgs e);
+ public partial class SqlNotificationEventArgs : System.EventArgs
+ {
+ public SqlNotificationEventArgs(SqlNotificationType type, SqlNotificationInfo info, SqlNotificationSource source) { }
+ public SqlNotificationType Type { get { throw null; } }
+ public SqlNotificationInfo Info { get { throw null; } }
+ public SqlNotificationSource Source { get { throw null; } }
+ }
+ public enum SqlNotificationInfo
+ {
+ Truncate = 0,
+ Insert = 1,
+ Update = 2,
+ Delete = 3,
+ Drop = 4,
+ Alter = 5,
+ Restart = 6,
+ Error = 7,
+ Query = 8,
+ Invalid = 9,
+ Options = 10,
+ Isolation = 11,
+ Expired = 12,
+ Resource = 13,
+ PreviousFire = 14,
+ TemplateLimit = 15,
+ Merge = 16,
+ Unknown = -1,
+ AlreadyChanged = -2
+ }
+ public enum SqlNotificationSource
+ {
+ Data = 0,
+ Timeout = 1,
+ Object = 2,
+ Database = 3,
+ System = 4,
+ Statement = 5,
+ Environment = 6,
+ Execution = 7,
+ Owner = 8,
+ Unknown = -1,
+ Client = -2
+ }
+ public enum SqlNotificationType
+ {
+ Change = 0,
+ Subscribe = 1,
+ Unknown = -1
+ }
public sealed partial class SqlRowUpdatedEventArgs : System.Data.Common.RowUpdatedEventArgs
{
public SqlRowUpdatedEventArgs(DataRow row, IDbCommand command, StatementType statementType, System.Data.Common.DataTableMapping tableMapping)
diff --git a/src/System.Data.SqlClient/src/Resources/Strings.resx b/src/System.Data.SqlClient/src/Resources/Strings.resx
index bb9f94ce37f3..dc59e7026d80 100644
--- a/src/System.Data.SqlClient/src/Resources/Strings.resx
+++ b/src/System.Data.SqlClient/src/Resources/Strings.resx
@@ -667,6 +667,33 @@
Number of fields in record '{0}' does not match the number in the original record.
+
+ This SqlCommand object is already associated with another SqlDependency object.
+
+
+ The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.
+
+
+ When using SqlDependency without providing an options value, SqlDependency.Start() must be called prior to execution of a command added to the SqlDependency instance.
+
+
+ When using SqlDependency without providing an options value, SqlDependency.Start() must be called for each server that is being executed against.
+
+
+ SqlDependency.Start has been called for the server the command is executing against more than once, but there is no matching server/user/database Start() call for current command.
+
+
+ SqlDependency.OnChange does not support multiple event registrations for the same delegate.
+
+
+ No SqlDependency exists for the key.
+
+
+ Timeout specified is invalid. Timeout cannot be < 0.
+
+
+ SqlDependency does not support calling Start() with different connection strings having the same server, user, and database in the same app domain.
+
The dbType {0} is invalid for this constructor.
diff --git a/src/System.Data.SqlClient/src/System.Data.SqlClient.csproj b/src/System.Data.SqlClient/src/System.Data.SqlClient.csproj
index a529906a63be..749e243a2f51 100644
--- a/src/System.Data.SqlClient/src/System.Data.SqlClient.csproj
+++ b/src/System.Data.SqlClient/src/System.Data.SqlClient.csproj
@@ -86,6 +86,7 @@
+
@@ -113,6 +114,9 @@
+
+
+
@@ -123,6 +127,11 @@
+
+
+
+
+
diff --git a/src/System.Data.SqlClient/src/System/Data/Common/AdapterUtil.SqlClient.cs b/src/System.Data.SqlClient/src/System/Data/Common/AdapterUtil.SqlClient.cs
index eb411a5a9246..05614321ba6f 100644
--- a/src/System.Data.SqlClient/src/System/Data/Common/AdapterUtil.SqlClient.cs
+++ b/src/System.Data.SqlClient/src/System/Data/Common/AdapterUtil.SqlClient.cs
@@ -47,6 +47,12 @@ internal static Exception ExceptionWithStackTrace(Exception e)
}
}
+ internal static void TraceExceptionWithoutRethrow(Exception e)
+ {
+ Debug.Assert(ADP.IsCatchableExceptionType(e), "Invalid exception type, should have been re-thrown!");
+ TraceException(" '%ls'\n", e);
+ }
+
//
// COM+ exceptions
//
diff --git a/src/System.Data.SqlClient/src/System/Data/Sql/SqlNotificationRequest.cs b/src/System.Data.SqlClient/src/System/Data/Sql/SqlNotificationRequest.cs
new file mode 100644
index 000000000000..88c2dc82226c
--- /dev/null
+++ b/src/System.Data.SqlClient/src/System/Data/Sql/SqlNotificationRequest.cs
@@ -0,0 +1,74 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System.Data.Common;
+using System.Data.SqlClient;
+
+namespace System.Data.Sql
+{
+ public sealed class SqlNotificationRequest
+ {
+ private string _userData;
+ private string _options;
+ private int _timeout;
+
+ public SqlNotificationRequest()
+ : this(null, null, SQL.SqlDependencyTimeoutDefault) { }
+
+ public SqlNotificationRequest(string userData, string options, int timeout)
+ {
+ UserData = userData;
+ Timeout = timeout;
+ Options = options;
+ }
+
+ public string Options
+ {
+ get
+ {
+ return _options;
+ }
+ set
+ {
+ if ((null != value) && (ushort.MaxValue < value.Length))
+ {
+ throw ADP.ArgumentOutOfRange(string.Empty, nameof(Options));
+ }
+ _options = value;
+ }
+ }
+
+ public int Timeout
+ {
+ get
+ {
+ return _timeout;
+ }
+ set
+ {
+ if (0 > value)
+ {
+ throw ADP.ArgumentOutOfRange(string.Empty, nameof(Timeout));
+ }
+ _timeout = value;
+ }
+ }
+
+ public string UserData
+ {
+ get
+ {
+ return _userData;
+ }
+ set
+ {
+ if ((null != value) && (ushort.MaxValue < value.Length))
+ {
+ throw ADP.ArgumentOutOfRange(string.Empty, nameof(UserData));
+ }
+ _userData = value;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/System.Data.SqlClient/src/System/Data/SqlClient/OnChangedEventHandler.cs b/src/System.Data.SqlClient/src/System/Data/SqlClient/OnChangedEventHandler.cs
new file mode 100644
index 000000000000..ce8b2cb8efec
--- /dev/null
+++ b/src/System.Data.SqlClient/src/System/Data/SqlClient/OnChangedEventHandler.cs
@@ -0,0 +1,8 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Data.SqlClient
+{
+ public delegate void OnChangeEventHandler(object sender, SqlNotificationEventArgs e);
+}
\ No newline at end of file
diff --git a/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs b/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs
index 75cc51100ce0..7f5d1c4807ea 100644
--- a/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs
+++ b/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlBulkCopy.cs
@@ -486,7 +486,7 @@ private Task CreateAndExecuteInitialQueryAsync(out Bulk
{
string TDSCommand = CreateInitialQuery();
- Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true);
+ Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, null, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true);
if (executeTask == null)
{
@@ -743,7 +743,7 @@ private string AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet i
private Task SubmitUpdateBulkCommand(string TDSCommand)
{
- Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true);
+ Task executeTask = _parser.TdsExecuteSQLBatch(TDSCommand, this.BulkCopyTimeout, null, _stateObj, sync: !_isAsyncBulkCopy, callerHasConnectionLock: true);
if (executeTask == null)
{
diff --git a/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs b/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs
index 1f936a210f93..84cdab38de85 100644
--- a/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs
+++ b/src/System.Data.SqlClient/src/System/Data/SqlClient/SqlCommand.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System.Data.Common;
+using System.Data.Sql;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Runtime.CompilerServices;
@@ -23,6 +24,8 @@ public sealed class SqlCommand : DbCommand, ICloneable
private UpdateRowSource _updatedRowSource = UpdateRowSource.Both;
private bool _designTimeInvisible;
+ internal SqlDependency _sqlDep;
+
private static readonly DiagnosticListener _diagnosticListener = new DiagnosticListener(SqlClientDiagnosticListenerExtensions.DiagnosticListenerName);
private bool _parentOperationStarted = false;
@@ -182,6 +185,7 @@ private CachedAsyncState cachedAsyncState
// _rowsAffected is cumulative for ExecuteNonQuery across all rpc batches
internal int _rowsAffected = -1; // rows affected by the command
+ private SqlNotificationRequest _notification;
// transaction support
private SqlTransaction _transaction;
@@ -304,6 +308,27 @@ override protected DbConnection DbConnection
}
}
+ private SqlInternalConnectionTds InternalTdsConnection
+ {
+ get
+ {
+ return (SqlInternalConnectionTds)_activeConnection.InnerConnection;
+ }
+ }
+
+ public SqlNotificationRequest Notification
+ {
+ get
+ {
+ return _notification;
+ }
+ set
+ {
+ _sqlDep = null;
+ _notification = value;
+ }
+ }
+
internal SqlStatistics Statistics
{
get
@@ -1104,6 +1129,8 @@ private Task InternalExecuteNonQuery(TaskCompletionSource