When I run:
FlatDataSource flatDataSource = new FlatDataSource(); flatDataSource.Cube = FlatDataSource.GenerateInitialCube(list.AsQueryable().ElementType.Name); CubeMetadata cubeMetadata = new CubeMetadata(); cubeMetadata.DisplayName = "Sales Data"; cubeMetadata.DataTypeFullName = list.AsQueryable().ElementType.FullName; cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Total_Per_Student_Amount", DisplayName = "Total Amount Per Student", DisplayFormat = "{0:C2}" }); cubeMetadata.DimensionSettings.Add(new DimensionMetadata() { SourcePropertyName = "Total_Expense_Amount", DisplayName = "Total Expense Amount", DisplayFormat = "{0:C2}" }); flatDataSource.CubesSettings.Add(cubeMetadata);
I keep getting "Object reference not set to an instance of an object. It says that I need to use the "new" keyword. However, I have assigned new to both the flatDataSource object and the cubeMetadata object.
What am I doing wrong?
Hi,
Do you have any hierarchy descriptors attached?
Plamen.
I do not know what you mean. What are these?
Thanks for the help. All the instances had values. Once I defined the hierarchies it worked. Thanks again
The hierarchy descriptors allow you to organize your flat data in hierarchies. If in your data class you have a property with type of DateTime and have put to rows/columns the dimension, which is related to that property, you will see the default hierarchy used to display such data. Here is a good sample of what they are. Have a look at the code view section below the sample.
Back to your issue – could you check if you have any instance with nulls within its properties? That may cause the exception.