If you really wanted (not recommended) - yes, you could copy all fields over from the cloned entity (edited from textbox) to the EntityCollection's version of the entity.
Before copying, you can use these methods will help you find the correct entity within your EntityCollection:
''' <summary>
''' Returns an Entity instance from a Collection. Can be used to match Cloned entities.
''' </summary>
''' <param name="myCollection"></param>
''' <param name="myEntity"></param>
''' <param name="RequireDifferentInstance"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function GetCollectionEntityByObject(ByRef myCollection As IEntityCollection, ByRef myEntity As IEntity, Optional ByVal RequireDifferentInstance As Boolean = False) As IEntity
If myEntity Is Nothing Or myCollection Is Nothing Then Return Nothing
Dim myCollectionEntity As IEntity = GetCollectionEntityByObject(myCollection, myEntity.ObjectID)
'Same Instance? (not a clone)
If RequireDifferentInstance = True Then
If myCollectionEntity IsNot Nothing AndAlso ReferenceEquals(myEntity, myCollectionEntity) Then Return Nothing
End If
Return myCollectionEntity
End Function
Public Shared Function GetCollectionEntityByObject(ByRef myCollection As IEntityCollection, ByVal ObjectID As Guid) As IEntity
For Each tmpEntity As IEntity In myCollection
If tmpEntity.ObjectID = ObjectID Then
Return tmpEntity
End If
Next
Return Nothing
End Function
Public Shared Function GetCollectionEntityByPrimaryKey(ByRef myCollection As IEntityCollection, ByRef myEntity As IEntity) As IEntity
If myEntity Is Nothing Or myCollection Is Nothing Then Return Nothing
Dim myPrimaryKey As EntityField = GetPrimaryKeyField(myEntity)
'Filter Collection by Primary Key
Dim myFilter As New PredicateExpression(myPrimaryKey = myEntity.Fields(myPrimaryKey.Name).CurrentValue)
Dim myIndexes As List(Of Integer) = myCollection.FindMatches(myFilter)
If myIndexes.Count = 0 Then Return Nothing
If myIndexes.Count > 1 Then Throw New Exception("Found more than one match in Collection (" & CType(myCollection, Object).GetType.ToString & ") for PrimaryKey: " & myEntity.Fields(myPrimaryKey.Name).CurrentValue)
Return myCollection(myIndexes(0))
End Function
Hope this helps!
Ryan D. Hatch
PS. Again, the best way to do Undo/Cancel is to clone the entire entity graph before editing. If the user hits Ok/Save - don't do anything because the current entity graph was updated. If the user hits Cancel/Undo - redatabind to the cloned entity graph (which will restore the EntityCollection to its previous state)