Check if any data sources are unjoined in the query
When there are 2 or more tables in a query, I want to check if any of them are unjoined. This is with the ASP.NET edition
Then is there an easier way to do this?
private bool queryHasUnjoinedDataSources() {
var dataSources = new List<DataSource>();
QueryBuilderControl1.QueryBuilder.ActiveSubQuery.ActiveUnionSubquery.FromClause.GetDatasources(dataSources);
//if there are more than 1 table/view in the query, make sure it is joined to the other data sources
if (dataSources.Count > 1) {
var links = new ArrayList();
dataSources[0].Query.FromClause.GetLinksRecursive(links);
if (links.Count == 0) {
return true;
}
var linkedDataSources = new System.Collections.Generic.HashSet<DataSource>();
foreach (Link link in links) {
linkedDataSources.Add(link.LeftDatasource);
linkedDataSources.Add(link.RightDatasource);
}
foreach (DataSource dataSource in dataSources) {
if (!linkedDataSources.Contains(dataSource)) {
return true;
}
}
}
//if we got here, all of the dataSources have joins
return false;
}
Thank you