Esempio n. 1
0
        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());
        }
Esempio n. 2
0
 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)));
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
        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)));
        }
Esempio n. 5
0
        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);
                }
        }
Esempio n. 6
0
 public XpoStore(XpoDatabase database)
 {
     _Database = database;
 }
Esempio n. 7
0
 public XPDataStore(XpoDatabase db, XPDataValidator <TKey, TModel, TXPOClass> validator = null)
 {
     xpo = db;
     val = validator;
 }