/// <summary> /// Gets a reference to a <see cref="DomainObject"/> with the given <see cref="ObjectID"/> in a specific <see cref="ClientTransaction"/>. If the /// transaction does not currently hold an object with this <see cref="ObjectID"/>, an object reference representing that <see cref="ObjectID"/> /// is created without calling a constructor and without loading the object's data from the data source. This method does not check whether an /// object with the given <see cref="ObjectID"/> actually exists in the data source. /// </summary> /// <param name="clientTransaction">The <see cref="ClientTransaction"/> to get the reference from.</param> /// <param name="objectID">The <see cref="ObjectID"/> to get an object reference for.</param> /// <returns> /// An object with the given <see cref="ObjectID"/>, possibly in <see cref="StateType.NotLoadedYet"/> state. /// </returns> /// <remarks> /// When an object with the given <paramref name="objectID"/> has already been enlisted in the transaction, that object is returned. Otherwise, /// an object in <see cref="StateType.NotLoadedYet"/> state is created and enlisted without loading its data from the data source. In such a case, /// the object's data is loaded when it's first needed; e.g., when one of its properties is accessed or when /// <see cref="DomainObjectExtensions.EnsureDataAvailable"/> is called on it. At that point, an /// <see cref="ObjectsNotFoundException"/> may be triggered when the object's data cannot be found. /// </remarks> /// <exception cref="ArgumentNullException">One of the parameters passed to this method is <see langword="null"/>.</exception> /// <exception cref="ObjectInvalidException">The object with the given <paramref name="objectID"/> is invalid in the given /// <paramref name="clientTransaction"/>.</exception> public static DomainObject GetObjectReference(ClientTransaction clientTransaction, ObjectID objectID) { ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction); ArgumentUtility.CheckNotNull("objectID", objectID); return(clientTransaction.GetObjectReference(objectID)); }
public override DomainObject GetOriginalOppositeObject() { if (OriginalOppositeObjectID == null) { return(null); } return(ClientTransaction.GetObjectReference(OriginalOppositeObjectID)); }
public void VisitFreshlyLoadedObject(FreshlyLoadedObjectData freshlyLoadedObjectData) { ArgumentUtility.CheckNotNull("freshlyLoadedObjectData", freshlyLoadedObjectData); var consolidatedData = _dataPendingRegistrationCollector.Add(freshlyLoadedObjectData); _loadedObjectData.Add(consolidatedData); if (consolidatedData == freshlyLoadedObjectData) { var domainObject = _clientTransaction.GetObjectReference(freshlyLoadedObjectData.FreshlyLoadedDataContainer.ID); freshlyLoadedObjectData.FreshlyLoadedDataContainer.SetDomainObject(domainObject); } }
public DomainObject GetDomainObjectReference() { if (ObjectID == null) { return(null); } if (ClientTransaction.IsInvalid(ObjectID)) { return(ClientTransaction.GetInvalidObjectReference(ObjectID)); } return(ClientTransaction.GetObjectReference(ObjectID)); }
private static IDataManagementCommand CreateMarkNotInvalidCommand(ClientTransaction tx, ObjectID objectID) { if (!tx.IsInvalid(objectID)) { var message = string.Format( "Cannot resurrect object '{0}' because it is not invalid within the whole transaction hierarchy. In transaction '{1}', the object has " + "state '{2}'.", objectID, tx, tx.GetObjectReference(objectID).TransactionContext[tx].State); var exception = new InvalidOperationException(message); return(new ExceptionCommand(exception)); } return(new MarkNotInvalidCommand(tx.DataManager, objectID)); }
public override void ObjectsNotFound(ClientTransaction clientTransaction, ReadOnlyCollection <ObjectID> objectIDs) { ArgumentUtility.CheckNotNull("clientTransaction", clientTransaction); ArgumentUtility.CheckNotNull("objectIDs", objectIDs); foreach (var objectID in objectIDs) { var objectReference = clientTransaction.GetObjectReference(objectID); for (var tx = clientTransaction; tx != null; tx = tx.SubTransaction) { using (tx.HierarchyManager.UnlockIfRequired()) { tx.DataManager.MarkInvalid(objectReference); } } } }