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 Task <T[]> CloneCollectionAsync <T>(CriteriaOperator sourceCriteria, SortProperty[] sortProperties, XpoDatabase target, bool synchronize = true, IEnumerable <XPClassInfo> excludedClasses = null, IEnumerable <string> synchronizeProperties = null) where T : IXPSimpleObject { return(Task.FromResult(CloneCollection <T>(sourceCriteria, sortProperties, target, synchronize, excludedClasses, synchronizeProperties))); }
public XPDataStore(XpoDatabase db, IXPDataMapper <TKey, TModel, TXPOClass> mapper, IXPDataStoreValidator <TKey, TModel, TXPOClass> validator = null) { if (db == null) { throw new ArgumentNullException("db"); } if (mapper == null) { throw new ArgumentNullException("mapper"); } DB = db; Mapper = mapper; Validator = validator; }
public virtual Task <T> CloneAsync <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("targetSession"); //T result; //using (Session sourceSession = this.GetSession()) //using (UnitOfWork targetSession = target.GetUnitOfWork()) //{ // Cloner c = new Cloner(sourceSession, targetSession, excludedClasses, synchronizeProperties); // result = c.Clone<T>(source, synchronize); //} return(Task.FromResult(Clone(source, target, synchronize, excludedClasses, synchronizeProperties))); }
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); } }
public XpoStore(XpoDatabase database) { _Database = database; }
public XPDataStore(XpoDatabase db, XPDataValidator <TKey, TModel, TXPOClass> validator = null) { xpo = db; val = validator; }