public T[] CloneCollection <T>(CriteriaOperator sourceCriteria, SortProperty[] sortProperties, XpoDatabase target, bool synchronize = true, IEnumerable <XPClassInfo> excludedClasses = null, IEnumerable <string> synchronizeProperties = null) where T : IXPSimpleObject { if (target == null) { throw new ArgumentNullException("target"); } List <T> result = new List <T>(); using (Session sourceSession = this.GetSession()) { XPCollection sourceList = new XPCollection(sourceSession, typeof(T), sourceCriteria, sortProperties); if (sourceList.Count > 0) { using (UnitOfWork targetSession = target.GetUnitOfWork()) { Cloner c = new Cloner(/*sourceSession,*/ targetSession, excludedClasses, synchronizeProperties); foreach (T sourceItem in sourceList) { result.Add(c.Clone(sourceItem, synchronize)); } targetSession.CommitChanges(); } } } return(result.ToArray()); }
public T Clone <T>(T source, XpoDatabase target, bool synchronize = true, IEnumerable <XPClassInfo> excludedClasses = null, IEnumerable <string> synchronizeProperties = null) where T : IXPSimpleObject { if (source == null) { throw new ArgumentNullException("source"); } if (target == null) { throw new ArgumentNullException("target"); } using (Session sourceSession = this.GetSession()) using (UnitOfWork targetSession = target.GetUnitOfWork()) { Cloner c = new Cloner(/*sourceSession,*/ targetSession, excludedClasses, synchronizeProperties); T result = c.Clone(source, synchronize); targetSession.CommitChanges(); return(result); } }
protected Session GetSession(bool transactional = false) { return(transactional ? _Database.GetUnitOfWork() : _Database.GetSession()); }