From 24beacb8b5cbf3f8863e91b42a75c2d93f0d921c Mon Sep 17 00:00:00 2001 From: Igor Timarac Date: Tue, 16 Dec 2014 11:24:18 +0100 Subject: [PATCH 1/3] Handling infinity results in a graceful manner. --- MdxClient/MdxCommand.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/MdxClient/MdxCommand.cs b/MdxClient/MdxCommand.cs index 7a9cc36..d71d852 100644 --- a/MdxClient/MdxCommand.cs +++ b/MdxClient/MdxCommand.cs @@ -27,6 +27,7 @@ public class MdxCommand : DbCommand private readonly XNamespace _namespace = "urn:schemas-microsoft-com:xml-analysis:mddataset"; private readonly XNamespace _xsiNs = "http://www.w3.org/2001/XMLSchema-instance"; private IEnumerable _columnMap; + private static readonly string[] invalid = new[] { "NAN", "INF", "-INF" }; #endregion #region constructors @@ -613,8 +614,12 @@ private void AddRows(IEnumerable rows, List cells, int rowColumnCou // this is done because the xml coming back does not include nulls/empty data. We have to fill in the gap or the subsequent objects will throw the data off if (Convert.ToInt32(cell.Ordinal) == i) { - cellToAdd = cell; - AdjustValueFromColumnType(cellToAdd, cell.Ordinal % (columnCountFromColumnAxis) + rowColumnCount, crs); + // Do this only if it's not infinity or NaN + if (!(cell.Type != "xsd:string" && cell.Value != null && invalid.Contains(cell.Value.ToString()))) + { + cellToAdd = cell; + AdjustValueFromColumnType(cellToAdd, cell.Ordinal % (columnCountFromColumnAxis) + rowColumnCount, crs); + } cellsIndexer++; } } From 0e1aa2ac1c06bcdef6b7ec05987fa9c074810dfe Mon Sep 17 00:00:00 2001 From: Igor T Date: Wed, 17 Dec 2014 22:49:48 +0100 Subject: [PATCH 2/3] Exposing SessionID and Close(bool) for easier implementation of connection pooling. --- MdxClient/MdxConnection.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MdxClient/MdxConnection.cs b/MdxClient/MdxConnection.cs index be2db36..d7ff4e4 100644 --- a/MdxClient/MdxConnection.cs +++ b/MdxClient/MdxConnection.cs @@ -41,6 +41,12 @@ internal AdomdConnection Connection } } + public String SessionID + { + get { return _connection.SessionID; } + set { _connection.SessionID = value; } + } + protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel) { if (IsolationLevel.Unspecified == isolationLevel || IsolationLevel.ReadCommitted == isolationLevel) From d2c5f9e76b549c28ccc02b6159684a7d6f35f677 Mon Sep 17 00:00:00 2001 From: Igor Timarac Date: Thu, 18 Dec 2014 09:02:44 +0100 Subject: [PATCH 3/3] Exposing Close(endSession) method for the connection. --- MdxClient/MdxConnection.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MdxClient/MdxConnection.cs b/MdxClient/MdxConnection.cs index d7ff4e4..ad6f21b 100644 --- a/MdxClient/MdxConnection.cs +++ b/MdxClient/MdxConnection.cs @@ -73,6 +73,15 @@ public override void Close() _connection.Close(); } + /// + /// Closes the connection to the database, while giving an option to leave the session open. + /// + /// If false, the session will remain open so it can be reused + public void Close(bool endSession) + { + _connection.Close(endSession); + } + /// /// Gets or sets the string used to open a SQL Server Analysis Services database. ///