/// <summary> /// Loads the object with the specified <see cref="ObjectID"/> into the transporter. /// </summary> /// <param name="objectID">The <see cref="ObjectID"/> of the object to load.</param> /// <returns>The loaded object, whose properties can be manipulated before it is transported.</returns> /// <remarks> /// <para> /// This method loads exactly the object with the given ID, it will not load any related objects. /// </para> /// <para> /// If an object has the foreign key side of a relationship and the related object is not loaded into this transporter, the relationship /// will still be transported. The related object must exist at the target system, otherwise an exception is thrown in /// <see cref="LoadTransportData(System.IO.Stream)"/>. /// </para> /// <para> /// If an object has the virtual side of a relationship and the related object is not loaded into this transporter, the relationship /// will not be transported. Its status after <see cref="LoadTransportData(System.IO.Stream)"/> depends on the objects at the target system. This /// also applies to the 1-side of a 1-to-n relationship because the n-side is the foreign key side. /// </para> /// </remarks> public DomainObject Load(ObjectID objectID) { ArgumentUtility.CheckNotNull("objectID", objectID); DomainObject domainObject = _transportTransaction.GetObject(objectID, false); _transportedObjects.Add(objectID); return(domainObject); }
private void SynchronizeData(ClientTransaction targetTransaction, IEnumerable <Tuple <TransportItem, DataContainer> > sourceToTargetMapping) { foreach (Tuple <TransportItem, DataContainer> sourceToTargetContainer in sourceToTargetMapping) { TransportItem transportItem = sourceToTargetContainer.Item1; DataContainer targetContainer = sourceToTargetContainer.Item2; PropertyIndexer targetProperties = new PropertyIndexer(targetContainer.DomainObject); foreach (KeyValuePair <string, object> sourceProperty in transportItem.Properties) { PropertyAccessor targetProperty = targetProperties[sourceProperty.Key, targetTransaction]; switch (targetProperty.PropertyData.Kind) { case PropertyKind.PropertyValue: targetProperty.SetValueWithoutTypeCheck(sourceProperty.Value); break; case PropertyKind.RelatedObject: if (!targetProperty.PropertyData.RelationEndPointDefinition.IsVirtual) { var relatedObjectID = (ObjectID)sourceProperty.Value; var targetRelatedObject = relatedObjectID != null?targetTransaction.GetObject(relatedObjectID, false) : null; targetProperty.SetValueWithoutTypeCheck(targetRelatedObject); } break; } } } }
/// <summary> /// Gets a <see cref="DomainObject"/> that already exists or attempts to load it from the data source. If the object's data can't be found, an /// exception is thrown, and the object is marked <see cref="StateType.Invalid"/> in the <paramref name="clientTransaction"/>. /// </summary> /// <param name="clientTransaction">The <see cref="ClientTransaction"/>.</param> /// <param name="objectID">The <see cref="ObjectID"/> of the <see cref="DomainObject"/> that should be loaded. Must not be <see langword="null"/>.</param> /// <param name="includeDeleted">Indicates if the method should return <see cref="DomainObject"/>s that are already deleted.</param> /// <returns> /// The <see cref="DomainObject"/> with the specified <paramref name="objectID"/>. /// </returns> /// <exception cref="System.ArgumentNullException"><paramref name="clientTransaction"/> or <paramref name="objectID"/> are <see langword="null"/>.</exception> /// <exception cref="ObjectsNotFoundException"> /// The object could not be found in the data source. Note that the <see cref="ClientTransaction"/> marks /// not found objects as <see cref="StateType.Invalid"/>, so calling this API again witht he same <see cref="ObjectID"/> results in a /// <see cref="ObjectInvalidException"/> being thrown. /// </exception> /// <exception cref="ObjectInvalidException">The object is invalid in the <paramref name="clientTransaction"/>.</exception> /// <exception cref="Persistence.StorageProviderException"> /// The Mapping does not contain a class definition for the given <paramref name="objectID"/>.<br/> -or- <br/> /// An error occurred while reading a <see cref="PropertyValue"/>.<br/> -or- <br/> /// An error occurred while accessing the data source. /// </exception> /// <exception cref="ObjectDeletedException">The object has already been deleted and the <paramref name="includeDeleted"/> flag is /// <see langword="false" />.</exception> public static DomainObject GetObject(ClientTransaction clientTransaction, ObjectID objectID, bool includeDeleted) { ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction); ArgumentUtility.CheckNotNull("objectID", objectID); return(clientTransaction.GetObject(objectID, includeDeleted)); }
public DomainObject GetDomainObject() { if (ObjectID == null) { return(null); } if (ClientTransaction.IsInvalid(ObjectID)) { return(ClientTransaction.GetInvalidObjectReference(ObjectID)); } return(ClientTransaction.GetObject(ObjectID, true)); }
public DomainObject GetObject(ObjectID objectID) { ArgumentUtility.CheckNotNull("objectID", objectID); return(_parentTransaction.GetObject(objectID, false)); }