internal void LoadFromXml(XmlNode node) { string attr = XmlUtils.GetAttr(node, "ref-select-case"); this.FSelector = attr.Length == 0 ? (MetadataProperty)null : this.Property.Class.Properties.Need(attr); if (this.FSelector == null) { MetadataAssociationRef assRef = new MetadataAssociationRef(this, this.Refs.Count); assRef.LoadFromXml(node); this.Refs.Add(assRef); } else { foreach (XmlNode selectNode in node.SelectNodes("case")) { MetadataAssociationRef assRef = new MetadataAssociationRef(this, this.Refs.Count); assRef.LoadFromXml(selectNode); if (this.Refs.FindBySelectorValue((object)assRef.SelectorValue) == null) { ; } this.Refs.Add(assRef); } if (this.Refs.Count == 0) { throw new MetadataException("Не заданы варианты связи."); } this.FSelector.SetAssociation(this); } }
internal override void LoadValueFromDb(object value, object exValue, LoadContext loadContext) { DataId id = new DataId((string)DataProperty.EscapeFromDBNull(value)); DataObject dataObject = (DataObject)null; DataObjectChildList dataObjectChildList = (DataObjectChildList)null; if (!id.IsEmpty) { MetadataAssociationRefList refs = this.Metadata.Association.Refs; MetadataAssociationRef metadataAssociationRef = this.Metadata.Association.Selector == null ? refs[0] : refs.FindBySelectorValue(exValue); if (metadataAssociationRef == null) { throw new DataException(string.Format("Нарушение целостности данных.\n{0}\nОшибка: Невозможно определить класс связанного объекта по значению селектора '{1}'.\n", (object)this.SystemView, exValue)); } dataObject = this.Session[metadataAssociationRef.RefClass].EnsureCacheItem(id); if (dataObject.IsNull) { dataObject = (DataObject)null; } else if (this.Metadata.IsAggregation) { dataObjectChildList = dataObject.GetChilds(metadataAssociationRef.OwnerChildRef); if ((loadContext & LoadContext.FetchAllObjects) != (LoadContext)0) { dataObjectChildList.SetCompleted(true); } } } base.SetValue((object)dataObject); dataObjectChildList?.AttachChild(this.Object, true); }
internal MetadataChildRef(MetadataAssociationRef aggregationRef, int index) { this.AggregationRef = aggregationRef; aggregationRef.OwnerChildRef = this; this.ChildClass = aggregationRef.Association.Class; this.MemberName = aggregationRef.AggregationRoleMemberName; this.Index = index; }
public ExternalAssociationNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataAssociationRef externalAssociationRef) : base(navigation, predecessor, path) { this.ExternalAssociationRef = externalAssociationRef; }
public AssociationNavigationStep( SqlUtils.Navigation navigation, SqlUtils.NavigationStep predecessor, string path, MetadataAssociationRef associationRef) : base(navigation, predecessor, path) { this.AssociationRef = associationRef; }
internal MetadataChildRef Ensure(MetadataAssociationRef ownerRef) { MetadataChildRef metadataChildRef = this.Find(ownerRef.Association.Class); if (metadataChildRef == null) { metadataChildRef = new MetadataChildRef(ownerRef, this.FItems.Count); this.FItems.Add(metadataChildRef); } return(metadataChildRef); }
private AssociationRefLoadPlan EnsureAssociationRef( MetadataAssociationRef assRef, LoadPlan plan, LoadPlan.MergedPlans mergedPlans) { for (int index = 0; index < this.Links.Count; ++index) { AssociationRefLoadPlan link = this.Links[index]; if (link.Ref == assRef) { link.Plan.MergeWith(plan, mergedPlans); return(link); } } AssociationRefLoadPlan associationRefLoadPlan = new AssociationRefLoadPlan(assRef, plan); this.Links.Add((object)associationRefLoadPlan); return(associationRefLoadPlan); }
private void AssignValue(object value, bool isLoading) { bool isAggregation = this.Metadata.IsAggregation; DataObject dataObject1 = !isAggregation || !this.IsAssigned ? (DataObject)null : (DataObject)this.GetValue(); MetadataAssociationRef metadataAssociationRef1 = (MetadataAssociationRef)null; DataObject dataObject2 = (DataObject)value; if (!isLoading) { dataObject2 = this.Session.EnsureSessionObject(dataObject2); } if (DataObject.Assigned(dataObject2)) { metadataAssociationRef1 = this.Metadata.Association.Refs.Find(dataObject2.Class); if (metadataAssociationRef1 == null) { throw new DataException(string.Format("Попытка присвоить объект '{0}' свойству '{1}' объекта '{2}'", (object)dataObject2.Class.Name, (object)this.Metadata.Name, (object)this.Object.Class.Name)); } } else { dataObject2 = (DataObject)null; } base.SetValue((object)dataObject2); if (!isAggregation || DataObject.SameObjects(dataObject2, dataObject1)) { return; } if (DataObject.Assigned(dataObject1)) { MetadataAssociationRef metadataAssociationRef2 = this.Metadata.Association.Refs.Need(dataObject1.Class); dataObject1.GetChilds(metadataAssociationRef2.OwnerChildRef).DetachChild(this.Object, isLoading); } if (DataObject.Assigned(dataObject2)) { dataObject2.GetChilds(metadataAssociationRef1.OwnerChildRef).AttachChild(this.Object, isLoading); } }
public void EnsureProperty(MetadataProperty propertyMetadata) { if (propertyMetadata.IsData) { this.EnsureDataProperty(propertyMetadata); } else { if (!propertyMetadata.IsLink) { throw new DataException(string.Format("DataLoadPlan.EnsureProperty: Свойство {0}.{1}, добавляемое в план загрузки, не является простым типом или связанным объектом.", (object)this.Class.QTypeName, (object)propertyMetadata.Name)); } LoadPlan plan = (LoadPlan)null; for (int index = 0; index < propertyMetadata.Association.Refs.Count; ++index) { MetadataAssociationRef assRef = propertyMetadata.Association.Refs[index]; if (plan == null) { plan = new LoadPlan(assRef.RefClass); } this.EnsureAssociationRef(assRef, plan); } } }
internal DataObjectExternalLink(MetadataAssociationRef @ref, DataObject[] objects) { this.Ref = @ref; this.Objects = objects; }
public AssociationRefLoadPlan EnsureAssociationRef( MetadataAssociationRef assRef, LoadPlan plan) { return(this.EnsureAssociationRef(assRef, plan, new LoadPlan.MergedPlans())); }
public AssociationRefLoadPlan(MetadataAssociationRef assRef, LoadPlan plan) { this.Ref = assRef; this.Plan = LoadPlan.UseExistingOrCreateNew(plan, assRef.RefClass); }