/// <summary>
/// Applies the submitted changes to the working copy and persists the changes but does <b>NOT</b> check-in the dataset.
/// The changes are coming in the form of the tuples to be added, deleted, or editedVersion.
/// The general procedure of making changes is CheckOut, Edit (one or more times), CheckIn or Rollback.
/// there is no need to pass metadata, extendedPropertyValues, contentDescriptors .. as they can be assigned to the working copy version before sending it to the method.
/// Just if they are null, they will not affect the version.
/// The general procedure is CheckOut, Edit*, CheckIn or Rollback
/// While the dataset is checked out, all the changes go to the latest+1 version which acts like a working copy
/// </summary>
/// <param name="workingCopyDatasetVersion">The working copy version that accepts the changes.</param>
/// <param name="createdTuples">The list of the new tuples to be added to the working copy.</param>
/// <param name="editedTuples">The list of the tuples whose values have been changed and the changes should be considered in the working copy.</param>
/// <param name="deletedTuples">The list of existing tuples to be deleted from the working copy.</param>
/// <param name="unchangedTuples">to be removed</param>
/// <returns>The working copy having the changes applied on it.</returns>
public DatasetVersion EditDatasetVersion(DatasetVersion workingCopyDatasetVersion,
List<DataTuple> createdTuples, ICollection<DataTuple> editedTuples, ICollection<long> deletedTuples, ICollection<DataTuple> unchangedTuples = null
//,ICollection<ExtendedPropertyValue> extendedPropertyValues, ICollection<ContentDescriptor> contentDescriptors
)
{
workingCopyDatasetVersion.Dematerialize(false);
//preserve metadata and XmlExtendedPropertyValues for later use
var workingCopyDatasetVersionId = workingCopyDatasetVersion.Id;
var metadata = workingCopyDatasetVersion.Metadata;
var xmlExtendedPropertyValues = workingCopyDatasetVersion.XmlExtendedPropertyValues;
var contentDescriptors = workingCopyDatasetVersion.ContentDescriptors;
// do not move them to editDatasetVersion function
this.DatasetRepo.Evict();
this.DatasetVersionRepo.Evict();
this.DataTupleRepo.Evict();
this.DataTupleVerionRepo.Evict();
this.DatasetRepo.UnitOfWork.ClearCache();
// maybe its better to use Merge function ...
workingCopyDatasetVersion = this.DatasetVersionRepo.Get(workingCopyDatasetVersionId);
if (metadata != null)
workingCopyDatasetVersion.Metadata = metadata;
if (xmlExtendedPropertyValues != null)
workingCopyDatasetVersion.XmlExtendedPropertyValues = xmlExtendedPropertyValues;
if (contentDescriptors != null)
workingCopyDatasetVersion.ContentDescriptors = contentDescriptors;
return editDatasetVersion(workingCopyDatasetVersion, createdTuples, editedTuples, deletedTuples, unchangedTuples);
}