From 5464eaf786e8d5184d8c3eeba33982de2001352d Mon Sep 17 00:00:00 2001 From: Daniel Otykier Date: Wed, 10 Apr 2024 10:14:21 +0200 Subject: [PATCH 1/2] Implement the 'State' property on TomConnection, since the DmvExtractor now reads this property. Also, implemented a few other properties that can be inferred from the TOM Server object. --- src/Dax.Model.Extractor/Data/TomConnection.cs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Dax.Model.Extractor/Data/TomConnection.cs b/src/Dax.Model.Extractor/Data/TomConnection.cs index b3de5b2..29b8a7f 100644 --- a/src/Dax.Model.Extractor/Data/TomConnection.cs +++ b/src/Dax.Model.Extractor/Data/TomConnection.cs @@ -33,34 +33,29 @@ public void Dispose() { } - #region Methods and properties that throw a NotImplementedException + public ConnectionState State => Server.GetConnectionState(false); public string ConnectionString { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } + get { return Server.ConnectionString; } + set { throw new InvalidOperationException(); } } + public int ConnectionTimeout => Server.ConnectionInfo.Timeout; - public int ConnectionTimeout { - get { throw new NotImplementedException(); } - } - - public ConnectionState State { - get { throw new NotImplementedException(); } - } + #region Methods and properties that throw a NotSupportedException public IDbTransaction BeginTransaction() { - throw new NotImplementedException(); + throw new NotSupportedException(); } public IDbTransaction BeginTransaction(IsolationLevel il) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public void ChangeDatabase(string databaseName) { - throw new NotImplementedException(); + throw new NotSupportedException(); } #endregion From 187af1f1f9e9f7ea1ceded63817ff392f202315b Mon Sep 17 00:00:00 2001 From: Daniel Otykier Date: Wed, 10 Apr 2024 10:15:26 +0200 Subject: [PATCH 2/2] Use the 'CreateCommand' directly on the IDbConnection interface, when the passed connection object doesn't match any of the patterns. --- src/Dax.Model.Extractor/Data/IDbConnectionExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dax.Model.Extractor/Data/IDbConnectionExtensions.cs b/src/Dax.Model.Extractor/Data/IDbConnectionExtensions.cs index 4e2921c..b0b3aa6 100644 --- a/src/Dax.Model.Extractor/Data/IDbConnectionExtensions.cs +++ b/src/Dax.Model.Extractor/Data/IDbConnectionExtensions.cs @@ -13,7 +13,7 @@ public static IDbCommand CreateCommand(this IDbConnection connection, string com AdomdConnection adomdConnection => new AdomdCommand(commandText, adomdConnection), OleDbConnection oledbConnection => new OleDbCommand(commandText, oledbConnection), TomConnection tomConnection => new TomCommand(commandText, tomConnection), - _ => throw new ExtractorException(connection), + _ => connection.CreateCommand(commandText) }; } }