Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 internal virtual void LoadValue(object value) => this.SetValue(DataProperty.EscapeFromDBNull(value));
Exemplo n.º 3
0
 internal virtual void LoadValueFromDb(object value, object exValue, LoadContext loadContext) => this.SetValue(DataProperty.EscapeFromDBNull(value));