Example #1
0
 public void Paged()
 {
     using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", CommandType.Text, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"))
     {
         Mapping <ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map <ObjectClass1>("TestTable", "ID_", true, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
         TestObject.Map(x => x.ID, "ID_")
         .Map(x => x.StringValue, "StringValue_")
         .Map(x => x.FloatValue, "FloatValue_")
         .Map(x => x.BoolValue, "BoolValue_")
         .Map(x => x.LongValue, "LongValue_")
         .Map(x => x.StringMaxValue, "StringMaxValue_");
         List <ObjectClass1>     Objects2 = new List <ObjectClass1>();
         Utilities.Random.Random Rand     = new Utilities.Random.Random();
         for (int x = 0; x < 115; ++x)
         {
             ObjectClass1 TempObject = new ObjectClass1();
             TempObject.StringValue    = Rand.Next <string>(new RegexStringGenerator(10));
             TempObject.BoolValue      = Rand.Next <bool>();
             TempObject.FloatValue     = (float)Rand.NextDouble();
             TempObject.LongValue      = Rand.Next(0, 100);
             TempObject.StringMaxValue = Rand.Next <string>(new RegexStringGenerator(6000));
             Objects2.Add(TempObject);
         }
         Helper2.Save <ObjectClass1, int>(Objects2);
         IEnumerable <ObjectClass1> Objects = Helper2.Paged <ObjectClass1>();
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged <ObjectClass1>(CurrentPage: 1);
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged <ObjectClass1>(CurrentPage: 2);
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged <ObjectClass1>(CurrentPage: 3);
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged <ObjectClass1>(CurrentPage: 4);
         Assert.Equal(15, Objects.Count());
         Assert.Equal(5, Helper2.PageCount <ObjectClass1>());
     }
 }
        public void Paged()
        {
            Utilities.SQL.SQLHelper.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
            Utilities.SQL.SQLHelper.Map <ObjectClass1>("TestTable", "ID_", Database: "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false")
            .Map(x => x.ID, "ID_")
            .Map(x => x.StringValue, "StringValue_")
            .Map(x => x.FloatValue, "FloatValue_")
            .Map(x => x.BoolValue, "BoolValue_")
            .Map(x => x.LongValue, "LongValue_");
            ObjectClass1 TempObject = null;

            Utilities.Random.Random Rand = new Utilities.Random.Random();
            using (Utilities.SQL.SQLHelper ORM = new Utilities.SQL.SQLHelper("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"))
            {
                for (int x = 0; x < 115; ++x)
                {
                    TempObject             = new ObjectClass1();
                    TempObject.StringValue = Rand.Next <string>(new RegexStringGenerator(10));
                    TempObject.BoolValue   = Rand.Next <bool>();
                    TempObject.FloatValue  = (float)Rand.NextDouble();
                    TempObject.LongValue   = Rand.Next();
                    ORM.Save <ObjectClass1, int>(TempObject);
                }
                TempObject = null;
                IEnumerable <ObjectClass1> Objects = ORM.Paged <ObjectClass1>();
                Assert.Equal(25, Objects.Count());
                Objects = ORM.Paged <ObjectClass1>(CurrentPage: 1);
                Assert.Equal(25, Objects.Count());
                Objects = ORM.Paged <ObjectClass1>(CurrentPage: 2);
                Assert.Equal(25, Objects.Count());
                Objects = ORM.Paged <ObjectClass1>(CurrentPage: 3);
                Assert.Equal(25, Objects.Count());
                Objects = ORM.Paged <ObjectClass1>(CurrentPage: 4);
                Assert.Equal(15, Objects.Count());
                Assert.Equal(5, ORM.PageCount <ObjectClass1>());
            }
        }
 public void Paged()
 {
     Utilities.SQL.SQLHelper.Database("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
     Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_", Database: "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false")
             .Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_")
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_");
     ObjectClass1 TempObject = null;
     Utilities.Random.Random Rand = new Utilities.Random.Random();
     using (Utilities.SQL.SQLHelper ORM = new Utilities.SQL.SQLHelper("Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"))
     {
         for (int x = 0; x < 115; ++x)
         {
             TempObject = new ObjectClass1();
             TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10));
             TempObject.BoolValue = Rand.Next<bool>();
             TempObject.FloatValue = (float)Rand.NextDouble();
             TempObject.LongValue = Rand.Next();
             ORM.Save<ObjectClass1, int>(TempObject);
         }
         TempObject = null;
         IEnumerable<ObjectClass1> Objects = ORM.Paged<ObjectClass1>();
         Assert.Equal(25, Objects.Count());
         Objects = ORM.Paged<ObjectClass1>(CurrentPage: 1);
         Assert.Equal(25, Objects.Count());
         Objects = ORM.Paged<ObjectClass1>(CurrentPage: 2);
         Assert.Equal(25, Objects.Count());
         Objects = ORM.Paged<ObjectClass1>(CurrentPage: 3);
         Assert.Equal(25, Objects.Count());
         Objects = ORM.Paged<ObjectClass1>(CurrentPage: 4);
         Assert.Equal(15, Objects.Count());
         Assert.Equal(5, ORM.PageCount<ObjectClass1>());
     }
 }
 public void Paged()
 {
     using (Utilities.SQL.SQLHelper Helper2 = new Utilities.SQL.SQLHelper("", CommandType.Text, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false"))
     {
         Mapping<ObjectClass1> TestObject = Utilities.SQL.SQLHelper.Map<ObjectClass1>("TestTable", "ID_", true, "Data Source=localhost;Initial Catalog=TestDatabase;Integrated Security=SSPI;Pooling=false");
         TestObject.Map(x => x.ID, "ID_")
             .Map(x => x.StringValue, "StringValue_")
             .Map(x => x.FloatValue, "FloatValue_")
             .Map(x => x.BoolValue, "BoolValue_")
             .Map(x => x.LongValue, "LongValue_")
             .Map(x => x.StringMaxValue, "StringMaxValue_");
         List<ObjectClass1> Objects2 = new List<ObjectClass1>();
         Utilities.Random.Random Rand = new Utilities.Random.Random();
         for (int x = 0; x < 115; ++x)
         {
             ObjectClass1 TempObject = new ObjectClass1();
             TempObject.StringValue = Rand.Next<string>(new RegexStringGenerator(10));
             TempObject.BoolValue = Rand.Next<bool>();
             TempObject.FloatValue = (float)Rand.NextDouble();
             TempObject.LongValue = Rand.Next(0, 100);
             TempObject.StringMaxValue = Rand.Next<string>(new RegexStringGenerator(6000));
             Objects2.Add(TempObject);
         }
         Helper2.Save<ObjectClass1, int>(Objects2);
         IEnumerable<ObjectClass1> Objects = Helper2.Paged<ObjectClass1>();
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged<ObjectClass1>(CurrentPage: 1);
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged<ObjectClass1>(CurrentPage: 2);
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged<ObjectClass1>(CurrentPage: 3);
         Assert.Equal(25, Objects.Count());
         Objects = Helper2.Paged<ObjectClass1>(CurrentPage: 4);
         Assert.Equal(15, Objects.Count());
         Assert.Equal(5, Helper2.PageCount<ObjectClass1>());
     }
 }