public unionstatement(selectstatements selects, orderbystatement orderby) : this(false, selects, orderby) { }
public unionstatement(bool all, selectstatements selects) : this(all, selects, null) { }
public new orderbystatement OrderBy; /* a good example of meaningful shadowing */ public unionstatement(bool all, selectstatements selects, orderbystatement orderby) { All = all; Selects = selects; OrderBy = orderby; }
public unionstatement(selectstatements selects) : this(false, selects, null) { }
public override ITable[] DependentUpon() { List <ITable> result = new List <ITable>(); ITable tab; /* a view might depend on various tables and other views, too */ selectstatement stmt = ConstituentSelectStatement; selectstatements sts; /* [dlatikay 20160913] pass-through views might have their dependencies specified in attributes */ object[] da = Attribute.GetCustomAttributes(this.GetType(), typeof(DependencyAttribute), false); for (int i = 0; i < da.Length; ++i) { var attr = da[i] as DependencyAttribute; tab = TableobjectFromName(attr.Relation.Name); if (!result.Contains(tab)) { result.Add(tab); } } /* decompose possible unions */ var unionStatement = stmt as unionstatement; if (unionStatement != null) { sts = unionStatement.Selects; /* a union might contain multiple selects (at least two) */ } else { sts = new selectstatements() { stmt } }; /* a singular statement */ /* iterate all of them */ foreach (selectstatement st in sts) { /* 1. look in the tables */ if (st.Tables != null) { foreach (tableexpression tex in st.Tables) { tab = TableobjectFromName(tex.Tablename); if (!result.Contains(tab)) { result.Add(tab); } } } /* 2. look in the joins */ if (st.Joins != null) { foreach (joinstatement join in st.Joins) { tab = TableobjectFromName(join.Tablename); if (!result.Contains(tab)) { result.Add(tab); } } } /* 3. look in the subqueries that might reside in the where clause */ /* -!- not yet cared to implement */ /* 4. look in the subqueries that might reside in the field list */ /* -!- not yet cared to implement */ } /* deliver */ return(result.ToArray()); } ITable TableobjectFromName(string name) { try { return((ITable)Assembly.GetAssembly(this.GetType()).CreateInstance("dal.schema." + name)); } catch (Exception) { throw new ArgumentOutOfRangeException("name", String.Format("Failed to resolve the name \"{0}\" in the \"dal.schema\" namespace.", name)); } } }