Example #1
0
        public DBCollection[] SpanToNotLoadEnable(int spanNumbers)
        {
            var dbCollections = new DBCollection[spanNumbers];

            if (spanNumbers == 1)
            {
                return new[] { this }
            }
            ;
            for (int i = 1; i < spanNumbers + 1; i++)
            {
                var collection = new DBCollection(Session, ObjectType, true)
                {
                    Sorting = Sorting
                };
                dbCollections[i - 1] = collection;
            }
            int j = 0;

            for (int i = 0; i < Count; i++)
            {
                dbCollections[j].Add(this[i]);
                j++;
                if (j == spanNumbers)
                {
                    j = 0;
                }
            }

            return(dbCollections);
        }
Example #2
0
//        public string Serialize()
//        {
//            var objects = (object[]) ArrayList.Adapter(this).ToArray(ObjectType);
//            return StreamUtils.Serialize(objects, ObjectType);
//        }

        public static void RemoveAllById(DBCollection collection1, DBCollection collection2)
        {
            for (int i = collection1.Count - 1; i > -1; i--)
            {
                var    dbObject = (DBObject)collection1[i];
                object keyValue = dbObject.ClassInfo.KeyProperty.GetValue(dbObject);
                if (collection2.Lookup(keyValue) != null)
                {
                    collection1.Remove(dbObject);
                }
            }
        }
Example #3
0
        public static void DeleteAll(XPCollection xpCollection, bool disableConstrains)
        {
            var collection = new DBCollection(xpCollection);

            using (collection)
            {
                var xpPageSelector = new XPPageSelector(collection)
                {
                    PageSize = 100
                };
                for (int i = 0; i < xpPageSelector.PageCount; i++)
                {
                    xpPageSelector.CurrentPage = i;
                    for (int j = xpPageSelector.Collection.Count - 1; j > -1; j--)
                    {
                        var dbObject = (DBObject)xpCollection[j];
                        dbObject.ConstrainsDisabled = disableConstrains;
                        dbObject.Delete();
                    }
                }
            }
        }
Example #4
0
        public DBCollection[] SpanTo(int spanNumbers)
        {
            var dbCollections = new DBCollection[spanNumbers];

            if (spanNumbers < 2)
            {
                return new[] { this }
            }
            ;
            var arrayList = new ArrayList[spanNumbers];

            for (int i = 0; i < spanNumbers; i++)
            {
                arrayList[i] = new ArrayList {
                    0
                };
            }

            for (int i = 0; i < Count; i++)
            {
                for (int j = 1; j < spanNumbers + 1; j++)
                {
                    if (i < Count)
                    {
                        var ixpSimpleObject = (IXPSimpleObject)this[i];
                        arrayList[j - 1].Add(ixpSimpleObject.ClassInfo.KeyProperty.GetValue(ixpSimpleObject));
                        i++;
                    }
                }
                i--;
            }
            for (int i = 0; i < arrayList.Length; i++)
            {
                dbCollections[i] = new DBCollection(Session, ObjectType, new InOperator("ID", arrayList[i]),
                                                    SortProperties);
            }
            return(dbCollections);
        }
Example #5
0
 public static DBCollection GetColletion(Session session, Type objectType, int pageSize, int pageIndex)
 {
     var dbCollection = new DBCollection(session, objectType);
     return dbCollection.GetColletion(pageSize, pageIndex);
 }
Example #6
0
        public DBCollection[] SpanToNotLoadEnable(int spanNumbers)
        {
            var dbCollections = new DBCollection[spanNumbers];
            if (spanNumbers == 1)
                return new[] {this};
            for (int i = 1; i < spanNumbers + 1; i++)
            {
                var collection = new DBCollection(Session, ObjectType, true) {Sorting = Sorting};
                dbCollections[i - 1] = collection;
            }
            int j = 0;
            for (int i = 0; i < Count; i++)
            {
                dbCollections[j].Add(this[i]);
                j++;
                if (j == spanNumbers)
                    j = 0;
            }

            return dbCollections;
        }
Example #7
0
        public DBCollection[] SpanTo(int spanNumbers)
        {
            var dbCollections = new DBCollection[spanNumbers];
            if (spanNumbers < 2)
                return new[] {this};
            var arrayList = new ArrayList[spanNumbers];
            for (int i = 0; i < spanNumbers; i++)
            {
                arrayList[i] = new ArrayList {0};
            }

            for (int i = 0; i < Count; i++)
            {
                for (int j = 1; j < spanNumbers + 1; j++)
                {
                    if (i < Count)
                    {
                        var ixpSimpleObject = (IXPSimpleObject) this[i];
                        arrayList[j - 1].Add(ixpSimpleObject.ClassInfo.KeyProperty.GetValue(ixpSimpleObject));
                        i++;
                    }
                }
                i--;
            }
            for (int i = 0; i < arrayList.Length; i++)
                dbCollections[i] = new DBCollection(Session, ObjectType, new InOperator("ID", arrayList[i]),
                                                    SortProperties);
            return dbCollections;
        }
Example #8
0
//        public string Serialize()
//        {
//            var objects = (object[]) ArrayList.Adapter(this).ToArray(ObjectType);
//            return StreamUtils.Serialize(objects, ObjectType);
//        }

        public static void RemoveAllById(DBCollection collection1, DBCollection collection2)
        {
            for (int i = collection1.Count - 1; i > -1; i--)
            {
                var dbObject = (DBObject) collection1[i];
                object keyValue = dbObject.ClassInfo.KeyProperty.GetValue(dbObject);
                if (collection2.Lookup(keyValue) != null)
                    collection1.Remove(dbObject);
            }
        }
Example #9
0
 public static void DeleteAll(XPCollection xpCollection, bool disableConstrains)
 {
     var collection = new DBCollection(xpCollection);
     using (collection)
     {
         var xpPageSelector = new XPPageSelector(collection) {PageSize = 100};
         for (int i = 0; i < xpPageSelector.PageCount; i++)
         {
             xpPageSelector.CurrentPage = i;
             for (int j = xpPageSelector.Collection.Count - 1; j > -1; j--)
             {
                 var dbObject = (DBObject) xpCollection[j];
                 dbObject.ConstrainsDisabled = disableConstrains;
                 dbObject.Delete();
             }
         }
     }
 }
Example #10
0
 public static int GetLastKey(Session session, XPClassInfo classInfo)
 {
     Type type = GetBaseType(classInfo.ClassType);
     var collection = new DBCollection(session, type, null,
                                       new[]
                                           {new SortProperty("ID", SortingDirection.Descending)})
                          {TopReturnedObjects = 1};
     int value = collection.Count > 0
                     ? (int) ((IXPSimpleObject) collection[0]).ClassInfo.KeyProperty.GetValue(collection[0])
                     : 0;
     collection.Dispose();
     return value;
 }
Example #11
0
        public static DBCollection GetColletion(Session session, Type objectType, int pageSize, int pageIndex)
        {
            var dbCollection = new DBCollection(session, objectType);

            return(dbCollection.GetColletion(pageSize, pageIndex));
        }