public static CubeModel GenerateFromDataTable(DataTable table, Dictionary <string, DataType> columnTypes = null) { var model = new CubeModel(table.TableName); foreach (DataColumn col in table.Columns) { var type = DataType.Text; if (columnTypes != null) { if (!columnTypes.TryGetValue(col.ColumnName, out type)) { type = Helper.ToDataType(col.DataType); } } else { type = Helper.ToDataType(col.DataType); } var isMeasure = Helper.IsMeasure(type); if (isMeasure) { var measure = new MeasureModel(col.ColumnName, type); if (!string.IsNullOrEmpty(col.Caption)) { measure.Caption = col.Caption; } model.Measures.Add(measure); } else { var dimension = new DimensionModel(col.ColumnName, type); if (!string.IsNullOrEmpty(col.Caption)) { dimension.Caption = col.Caption; } model.Dimensions.Add(dimension); } } return(model); }
public static CubeModel GenerateFromDataTable(DataTable table, Dictionary<string, DataType> columnTypes = null) { var model = new CubeModel(table.TableName); foreach (DataColumn col in table.Columns) { var type = DataType.Text; if (columnTypes != null) { if (!columnTypes.TryGetValue(col.ColumnName, out type)) type = Helper.ToDataType(col.DataType); } else type = Helper.ToDataType(col.DataType); var isMeasure = Helper.IsMeasure(type); if (isMeasure) { var measure = new MeasureModel(col.ColumnName, type); if (!string.IsNullOrEmpty(col.Caption)) measure.Caption = col.Caption; model.Measures.Add(measure); } else { var dimension = new DimensionModel(col.ColumnName, type); if (!string.IsNullOrEmpty(col.Caption)) dimension.Caption = col.Caption; model.Dimensions.Add(dimension); } } return model; }