private void LoadQuerySimple() { UnionSubQuery unionSubQuery = _query.QueryRoot.FirstSelect(); // add three objects to the query DataSource ds1 = _query.AddObject(unionSubQuery, "MyDB.MySchema.Customers", "c"); DataSource ds2 = _query.AddObject(unionSubQuery, "MyDB.MySchema.Orders", "o"); DataSource ds3 = _query.AddObject(unionSubQuery, "MyDB.MySchema.Resellers", "r"); // create a relation between 'Resellers' and 'Orders' _query.AddLink(ds3, "ResellerID", ds2, "ResellerID"); // create WHERE condition QueryColumnListItem ci2 = unionSubQuery.QueryColumnList.AddExpression("CustomerID"); // do not add this item to the select list ci2.Selected = false; ci2.ConditionStrings[0] = "> 0"; // create an output column QueryColumnListItem ci3 = unionSubQuery.QueryColumnList.AddField(ds1, "CustomerName"); // add this item to the select list ci3.Selected = true; }