internal virtual bool Attach(QQuery query, string a_field) { Db4objects.Db4o.Internal.Query.Processor.QCon qcon = this; ClassMetadata yc = GetYapClass(); bool[] foundField = new bool[] { false }; ForEachChildField(a_field, new _IVisitor4_101(foundField, query)); if (foundField[0]) { return(true); } QField qf = null; if (yc == null || yc.HoldsAnyClass()) { int[] count = new int[] { 0 }; FieldMetadata[] yfs = new FieldMetadata[] { null }; i_trans.Container().ClassCollection().AttachQueryNode(a_field, new _IVisitor4_119 (yfs, count)); if (count[0] == 0) { return(false); } if (count[0] == 1) { qf = yfs[0].QField(i_trans); } else { qf = new QField(i_trans, a_field, null, 0, 0); } } else { if (yc.IsTranslated()) { i_trans.Container()._handlers.DiagnosticProcessor().DescendIntoTranslator(yc, a_field ); } FieldMetadata yf = yc.FieldMetadataForName(a_field); if (yf != null) { qf = yf.QField(i_trans); } if (qf == null) { qf = new QField(i_trans, a_field, null, 0, 0); } } QConPath qcp = new QConPath(i_trans, qcon, qf); query.AddConstraint(qcp); qcon.AddConstraint(qcp); return(true); }
// Our QConPath objects are just placeholders to fields, // so the parents are reachable. // If we find a "real" constraint, we throw the QPath // out and replace it with the other constraint. private void Morph(BooleanByRef removeExisting, QCon newConstraint, IReflectClass claxx) { bool mayMorph = true; if (claxx != null) { ClassMetadata yc = i_trans.Container().ProduceClassMetadata(claxx); if (yc != null) { IEnumerator i = IterateChildren(); while (i.MoveNext()) { QField qf = ((QCon)i.Current).GetField(); if (!yc.HasField(i_trans.Container(), qf.Name())) { mayMorph = false; break; } } } } // } if (mayMorph) { IEnumerator j = IterateChildren(); while (j.MoveNext()) { newConstraint.AddConstraint((QCon)j.Current); } if (HasJoins()) { IEnumerator k = IterateJoins(); while (k.MoveNext()) { QConJoin qcj = (QConJoin)k.Current; qcj.ExchangeConstraint(this, newConstraint); newConstraint.AddJoin(qcj); } } i_parent.ExchangeConstraint(this, newConstraint); removeExisting.value = true; } else { i_parent.AddConstraint(newConstraint); } }
// Our QConPath objects are just placeholders to fields, // so the parents are reachable. // If we find a "real" constraint, we throw the QPath // out and replace it with the other constraint. private void Morph(BooleanByRef removeExisting, QCon newConstraint, IReflectClass claxx) { bool mayMorph = true; if (claxx != null) { ClassMetadata yc = i_trans.Container().ProduceClassMetadata(claxx); if (yc != null) { IEnumerator i = IterateChildren(); while (i.MoveNext()) { QField qf = ((QCon)i.Current).GetField(); if (!yc.HasField(i_trans.Container(), qf.Name())) { mayMorph = false; break; } } } } // } if (mayMorph) { IEnumerator j = IterateChildren(); while (j.MoveNext()) { newConstraint.AddConstraint((QCon)j.Current); } if (HasJoins()) { IEnumerator k = IterateJoins(); while (k.MoveNext()) { QConJoin qcj = (QConJoin)k.Current; qcj.ExchangeConstraint(this, newConstraint); newConstraint.AddJoin(qcj); } } i_parent.ExchangeConstraint(this, newConstraint); removeExisting.value = true; } else { i_parent.AddConstraint(newConstraint); } }