| Visual Basic (Declaration) | |
|---|---|
Public Property ConnectTableSettings As System.String | |
| C# | |
|---|---|
public System.string ConnectTableSettings {get; set;} | |
This settings are useful for System.Data.DataSets with relations (see System.Data.DataRelation). They will be ignored if data source is not System.Data.DataSet, System.Data.DataView or System.Data.DataTable. Table settings must be in special format, which includes table name (first table by default), sort (System.Data.DataView.Sort) and filter (System.Data.DataView.RowFilter) settings. To use relations you must specify query field (GrapeCity.ActiveAnalysis.Schema.QueryFieldBuilder) with name 'NameOfRelationshipToTheTable.FieldName' and schema field (attribute, hierarchy or measure) with expression '=Fields("NameOfRelationshipToTheTable.FieldName").Value'.
The NWind sample below shows how you can use a dataset with multiple
tables without joining this dataset to one table.
In this case you must specify query fields using the relational names
between tables:
To use NWind as is (without joining it to a dataset in the SELECT part of a query).
To specify relational names.
To specify query fields by using relational names; then you can use the dataset as a data source with two tables.
To set the main table using the ConnectTableSettings property.
Possible values:
"Order Details"
"Order Details[sort:"Quantity DESC"]"
"Order Details[filter:"ProductID > 10"]"
"Order Details[sort:"Quantity DESC";filter:"ProductID > 10"]"
| C# | Copy Code |
|---|---|
DataSet ds = new DataSet(); OleDbConnection connection = new OleDbConnection(TestSettings.Relational.ConnectionString); connection.Open(); string[] tables = { "Order Details", "Orders"}; foreach (string table in tables) { using (IDbCommand command = connection.CreateCommand()) { command.CommandText = "select * from [" + table + "]"; using (IDataReader reader = command.ExecuteReader(CommandBehavior.Default)) ds.Load(reader, LoadOption.OverwriteChanges, table); } } | |
| C# | Copy Code |
|---|---|
ds.Relations.Add("OrderID", ds.Tables["Orders"].Columns["OrderID"], ds.Tables["Order Details"].Columns["OrderID"]); | |
| C# | Copy Code |
|---|---|
SchemaBuilder sb = SchemaBuilder.AutoGenerate("NWind", connection, "select * from [Order Details]"); sb.AddQueryField("OrderID.Freight"); sb.AddQueryField("OrderID.ShipVia"); ((MeasuresDimBuilder)sb.Dimensions["Measures"]).AddField( new MeasureBuilder("Freight").SetExpression("=Fields(\"OrderID.Freight\").Value", typeof(int))); ((AttributesDimBuilder)sb.Dimensions["Attributes"]).AddField( new AttributeBuilder("ShipVia").SetExpression("=Fields(\"OrderID.ShipVia\").Value", typeof(string))); | |
| C# | Copy Code |
|---|---|
UnboundDataSource dataSource = new UnboundDataSource(); dataSource.DataSource = ds; dataSource.CustomSchema = sb.BuildSchema(); dataSource.ConnectTableSettings = "Order Details"; | |
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2