Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7813743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:58:35+00:00 2026-06-02T04:58:35+00:00

(I am using C# 4.0. I am connecting to a data cube via the

  • 0

(I am using C# 4.0. I am connecting to a data cube via the Microsoft.AnalysisServices.AdomdClient namespace/library.)

If I understand correctly there is exactly one axis in an MDX SELECT statement that will contain measures; the others will be based on the other dimensions.

My immediate task (the larger task is irrelevant, I believe) is given an MDX SELECT statement such that the first axis contains said measures, I need to programmatically determine the data type of the all of the cells pertaining to each of the measures.

One way to do this, I think, would be to use the AdomdConnection and reference the CubeDef class to obtain measure information, and match that to Cellset.Set.Tuples.Members sort of thing, but then how does one account for on-the-fly measures from using the “WITH” keyword in a SELECT?

Another way could be to look at the Value property of Cell objects associated with a given measure from executing the SELECT statement and find a non-null Cell in the CellSet, but we’re not guaranteed to find a non-null value, so this is not fail-proof.

I’ve looked through a CellSet in the VS debugger and haven’t found any properties that give this information.

Solution:
As it turns out, it is possible for a measure to have multiple data types. At least for measures defined with a WITH clause, as follows:

WITH MEMBER [Measures].[Dud] AS CASE WHEN [Measures].[Original] > 500 THEN ‘A’ ELSE 0 END

Because of this, data type information is stored in each cell, and not in some sort of measures meta data. Subsequently, the only way to learn the schema is to assume that they’re all the same type, and then traverse through the measures dimension until you find a non-null cell and then learn its type.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:58:36+00:00Added an answer on June 2, 2026 at 4:58 am

    We actually wrote our own .NET Framework Data Provider based on the ADOMD data provider. We hope to open source it later this year, but below are some excerpts of how I did what you want to accomplish.

    I used the ExecuteXmlReader of a AdomdCommand object. The xml that is returned will have a portion for the cells.

    AdomdCommand command = new AdomdCommand();
    command.Connection = new AdomdConnection(connectionString);
    command.Connection.Open();
    command.CommandText = query;
    var doc = XDcoument.Load(command.ExecuteXmlReader());
    
    var cellData = from cell in doc.Root.Elements(_namespace + "CellData").Elements(_namespace + "Cell")
                           select new
                           {
                               Ordinal = (int)cell.Attribute("CellOrdinal"),
                               FormattedValue = cell.Elements(_namespace + "FmtValue").Any() ? cell.Element(_namespace + "FmtValue").Value : cell.Element(_namespace + "Value").Value,
                               Value = cell.Element(_namespace + "Value").Value,
                               Type = (string)cell.Element(_namespace + "Value").Attribute(_xsiNs + "type"),
    
                           };
    

    Each cell has a data type. For a given column, we need all the cells in that column.

    var x = cells.Where(c => ((c.Ordinal + 1) % columnCount) == columnPosition).Select(t => t.Type).Distinct();
     if (x.Count() > 1)
            {
                // if a non number comes back, the type is null, so non numbers are null
                // on counts of greater than 1 and no nulls, we have multiple number types, make them all double to accommodate the differences
                if ( !x.Contains(null) )
                {
                    // mix of numbers not doubles, default to int
                    if (!x.Contains("xsd:double"))
                    {
                        type = typeof(int);
                    }
                    else
                    {
                        type = typeof(double);
                    }
                }
                else
                {
                    type = typeof(string);
                }
            }
            else
            {
                // entire column maybe null, default to string, otherwise check
                if (x.Count() == 1)
                {
                    type = ConvertXmlTypeToType(x.First());
                }               
            }
    

    Finally I have function that converts Xml type to .NET type

    private Type ConvertXmlTypeToType(string type)
        {
            Type t = typeof(string);
    
            switch (type)
            {
                case "xsd:int":
                    t = typeof(int);
                    break;
                case "xsd:double":
                    t = typeof(double);
                    break;
                case "xsd:long":
                    t = typeof(long);
                    break;
                case "xsd:short":
                    t = typeof(short);
                    break;
                case "xsd:integer":
                    t = typeof(int);
                    break;
                case "xsd:decimal":
                    t = typeof(decimal);
                    break;
                case "xsd:float":
                    t = typeof(float);
                    break;
                default:
                    t = typeof(string);
                    break;
            }
    
            return t;
        }               
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am connecting to a legacy rdbms system using System.Data.OdbcClient. I would like to
This is the connection string I am using. string connection = Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\CULVERT2.DBF;Extended Properties=dBASE
Is there a way to get the timezone of the connecting user using Pylons,
I am using oracle 10g. When I was connecting with oracle data base. I
I am having problem connecting to iSeries DB2 using IBM.Data.DB2.iSeries, but I can easily
Hi I am currently writing a servlet using Apache XML-RPC connecting to OpenERP. There
we're currently building a data warehouse using OWB (Oracle Warehouse Builder). One of the
I am using System.data.sqlite for connecting to Sqlite Database, as per the Sqlite documentation
I'm using a many-to-many database with join tables connecting main data tables through foreign
I am using MongoDB to store data. In my project I am connecting multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.