facing issue in master relation of databands in designer
Posted: Fri Jan 16, 2026 9:58 am
I am using stimulsoft designer to design a report in a group by manner where the data is in the form of array of objects so i have used databands in master relation manner and it's working fine in designer preview but when i am exporting the report manually the details are not being displayed properly, this is my code ------
var result = await ExecuteGraphQL(
endpoint: gqlUrl,
query: gqlQuery,
variables: gqlVariables,
timeoutSeconds: 1200,
report: _report
);
// register result into report dataset
try
{
var items = (JArray)result[graphQLSource.Name]["items"];
LogTime(sw, $"[{_report.Name}] GraphQL response convert to DataTable started");
var table = ToDataTable(items, $"{graphQLSource.Name}_items");
LogTime(sw, $"[{_report.Name}] GraphQL response converted to DataTable");
datasources.Add($"{graphQLSource.Name}_items", table);
var payerProgramTable = CreateChildTable(
items,
"providerCategories", // array name in GraphQL
"id",
$"{graphQLSource.Name}_items_providerCategories"
);
datasources.Add($"{graphQLSource.Name}_items_providerCategories", payerProgramTable);
var treatmentTable = CreateItemsTreatmentTable(
items,
"id",
$"{graphQLSource.Name}_items_treatment"
);
datasources.Add($"{graphQLSource.Name}_items_treatment", treatmentTable);
var meenaProgramTable = CreateTreatmentProviderCategoriesTable(
items,
$"{graphQLSource.Name}_items_treatment_providerCategories"
);
datasources.Add($"{graphQLSource.Name}_items_treatment_providerCategories", meenaProgramTable);
var parent = report.Dictionary.DataSources[$"{graphQLSource.Name}_items"];
var child = report.Dictionary.DataSources[$"{graphQLSource.Name}_items_providerCategories"];
var treatment = report.Dictionary.DataSources[$"{graphQLSource.Name}_items_treatment"];
var treatmentChild = report.Dictionary.DataSources[$"{graphQLSource.Name}_items_treatment_providerCategories"];
if (parent != null && child != null)
{
var relation1 = new StiDataRelation("Items_PayerProgram", parent, child, new[] { "id" }, new[] { "parentId" });
report.Dictionary.Relations.Add(relation1);
}
if (parent != null && treatment != null)
{
var relation2 = new StiDataRelation("Items_treatment", parent, treatment, new[] { "id" }, new[] { "parentId" });
report.Dictionary.Relations.Add(relation2);
}
if (treatment != null && treatmentChild != null)
{
var relation3 = new StiDataRelation("Items_MeenaProgram", treatment, treatmentChild, new[] { "id" }, new[] { "treatmentId" });
report.Dictionary.Relations.Add(relation3);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "exception occur while setting data into dictionary");
throw;
} if (datasources.Any())
{
// Step 1: Extract relation information BEFORE clearing
var relationInfo = report.Dictionary.Relations.Cast<StiDataRelation>()
.Select(r => new
{
Name = r.Name,
ParentSourceName = r.ParentSource.Name,
ChildSourceName = r.ChildSource.Name,
ParentColumns = r.ParentColumns.ToArray(),
ChildColumns = r.ChildColumns.ToArray()
})
.ToList();
_logger.LogInformation($"Saved {relationInfo.Count} relations before clearing");
// Step 2: Clear everything
report.Dictionary.DataSources.Clear();
report.Dictionary.Databases.Clear();
report.Dictionary.Relations.Clear();
// Step 3: Register new data sources
foreach (KeyValuePair<string, DataTable> ds in datasources)
{
report.RegData(ds.Key, ds.Value);
_logger.LogInformation($"Registered data source: {ds.Key}");
}
// Step 4: Synchronize to ensure data sources are available
report.Dictionary.Synchronize();
LogTime(sw, $"[{_report.Name}] Report dictionary data set");
// Step 5: Recreate relations using the saved information
foreach (var relInfo in relationInfo)
{
try
{
// Get the NEW data source references by name
var parentSource = report.Dictionary.DataSources[relInfo.ParentSourceName];
var childSource = report.Dictionary.DataSources[relInfo.ChildSourceName];
if (parentSource != null && childSource != null)
{
var newRelation = new StiDataRelation(
relInfo.Name,
parentSource,
childSource,
relInfo.ParentColumns,
relInfo.ChildColumns
);
report.Dictionary.Relations.Add(newRelation);
_logger.LogInformation($"Restored relation: {relInfo.Name} ({relInfo.ParentSourceName}.{string.Join(",", relInfo.ParentColumns)} -> {relInfo.ChildSourceName}.{string.Join(",", relInfo.ChildColumns)})");
}
else
{
_logger.LogWarning($"Could not restore relation {relInfo.Name}. Parent '{relInfo.ParentSourceName}' found: {parentSource != null}, Child '{relInfo.ChildSourceName}' found: {childSource != null}");
}
}
catch (Exception ex)
{
_logger.LogError(ex, $"Error restoring relation {relInfo.Name}");
}
}
foreach (StiDataBand band in report.GetComponents().OfType<StiDataBand>())
{
if (band.DataRelation != null && band.MasterComponent != null)
{
band.MasterComponent = null;
}
}
// Step 6: Final synchronization
report.Dictionary.Synchronize();
LogTime(sw, $"[{_report.Name}] Report relations restored");
}
when i am not doing master component null no data for payer program or meena program is being displayed and when i am doing it the data are not being displayed relation wise, i have also created new relation but am not sure if it's even using those relation as databands have their own relation and the table columns that i have created, and the ones present in databands data relation are different so that could also be the problem but i don't know how am i supposed to fix it, I have attached my designer image to, please do check. I would appreciate help as soon as possible.
var result = await ExecuteGraphQL(
endpoint: gqlUrl,
query: gqlQuery,
variables: gqlVariables,
timeoutSeconds: 1200,
report: _report
);
// register result into report dataset
try
{
var items = (JArray)result[graphQLSource.Name]["items"];
LogTime(sw, $"[{_report.Name}] GraphQL response convert to DataTable started");
var table = ToDataTable(items, $"{graphQLSource.Name}_items");
LogTime(sw, $"[{_report.Name}] GraphQL response converted to DataTable");
datasources.Add($"{graphQLSource.Name}_items", table);
var payerProgramTable = CreateChildTable(
items,
"providerCategories", // array name in GraphQL
"id",
$"{graphQLSource.Name}_items_providerCategories"
);
datasources.Add($"{graphQLSource.Name}_items_providerCategories", payerProgramTable);
var treatmentTable = CreateItemsTreatmentTable(
items,
"id",
$"{graphQLSource.Name}_items_treatment"
);
datasources.Add($"{graphQLSource.Name}_items_treatment", treatmentTable);
var meenaProgramTable = CreateTreatmentProviderCategoriesTable(
items,
$"{graphQLSource.Name}_items_treatment_providerCategories"
);
datasources.Add($"{graphQLSource.Name}_items_treatment_providerCategories", meenaProgramTable);
var parent = report.Dictionary.DataSources[$"{graphQLSource.Name}_items"];
var child = report.Dictionary.DataSources[$"{graphQLSource.Name}_items_providerCategories"];
var treatment = report.Dictionary.DataSources[$"{graphQLSource.Name}_items_treatment"];
var treatmentChild = report.Dictionary.DataSources[$"{graphQLSource.Name}_items_treatment_providerCategories"];
if (parent != null && child != null)
{
var relation1 = new StiDataRelation("Items_PayerProgram", parent, child, new[] { "id" }, new[] { "parentId" });
report.Dictionary.Relations.Add(relation1);
}
if (parent != null && treatment != null)
{
var relation2 = new StiDataRelation("Items_treatment", parent, treatment, new[] { "id" }, new[] { "parentId" });
report.Dictionary.Relations.Add(relation2);
}
if (treatment != null && treatmentChild != null)
{
var relation3 = new StiDataRelation("Items_MeenaProgram", treatment, treatmentChild, new[] { "id" }, new[] { "treatmentId" });
report.Dictionary.Relations.Add(relation3);
}
}
catch (Exception ex)
{
_logger.LogError(ex, "exception occur while setting data into dictionary");
throw;
} if (datasources.Any())
{
// Step 1: Extract relation information BEFORE clearing
var relationInfo = report.Dictionary.Relations.Cast<StiDataRelation>()
.Select(r => new
{
Name = r.Name,
ParentSourceName = r.ParentSource.Name,
ChildSourceName = r.ChildSource.Name,
ParentColumns = r.ParentColumns.ToArray(),
ChildColumns = r.ChildColumns.ToArray()
})
.ToList();
_logger.LogInformation($"Saved {relationInfo.Count} relations before clearing");
// Step 2: Clear everything
report.Dictionary.DataSources.Clear();
report.Dictionary.Databases.Clear();
report.Dictionary.Relations.Clear();
// Step 3: Register new data sources
foreach (KeyValuePair<string, DataTable> ds in datasources)
{
report.RegData(ds.Key, ds.Value);
_logger.LogInformation($"Registered data source: {ds.Key}");
}
// Step 4: Synchronize to ensure data sources are available
report.Dictionary.Synchronize();
LogTime(sw, $"[{_report.Name}] Report dictionary data set");
// Step 5: Recreate relations using the saved information
foreach (var relInfo in relationInfo)
{
try
{
// Get the NEW data source references by name
var parentSource = report.Dictionary.DataSources[relInfo.ParentSourceName];
var childSource = report.Dictionary.DataSources[relInfo.ChildSourceName];
if (parentSource != null && childSource != null)
{
var newRelation = new StiDataRelation(
relInfo.Name,
parentSource,
childSource,
relInfo.ParentColumns,
relInfo.ChildColumns
);
report.Dictionary.Relations.Add(newRelation);
_logger.LogInformation($"Restored relation: {relInfo.Name} ({relInfo.ParentSourceName}.{string.Join(",", relInfo.ParentColumns)} -> {relInfo.ChildSourceName}.{string.Join(",", relInfo.ChildColumns)})");
}
else
{
_logger.LogWarning($"Could not restore relation {relInfo.Name}. Parent '{relInfo.ParentSourceName}' found: {parentSource != null}, Child '{relInfo.ChildSourceName}' found: {childSource != null}");
}
}
catch (Exception ex)
{
_logger.LogError(ex, $"Error restoring relation {relInfo.Name}");
}
}
foreach (StiDataBand band in report.GetComponents().OfType<StiDataBand>())
{
if (band.DataRelation != null && band.MasterComponent != null)
{
band.MasterComponent = null;
}
}
// Step 6: Final synchronization
report.Dictionary.Synchronize();
LogTime(sw, $"[{_report.Name}] Report relations restored");
}
when i am not doing master component null no data for payer program or meena program is being displayed and when i am doing it the data are not being displayed relation wise, i have also created new relation but am not sure if it's even using those relation as databands have their own relation and the table columns that i have created, and the ones present in databands data relation are different so that could also be the problem but i don't know how am i supposed to fix it, I have attached my designer image to, please do check. I would appreciate help as soon as possible.