コード例 #1
0
        public void Test1()
        {
            var table = ents.GetTable <Tweets>();

            byte[] buf = new byte[256];
            for (int i = 0; i < 256; i++)
            {
                buf[i] = (byte)i;
            }

            int           RowsNo = 2000;
            List <Tweets> entL   = new List <Tweets>();

            for (int i = 0; i < RowsNo; i++)
            {
                var ent = new Tweets()
                {
                    tweet_id = Guid.NewGuid(), author = "test" + i.ToString(), body = "body" + i.ToString(), isok = (i % 2 == 0)
                };
                ent.exampleSet.Add(i.ToString());
                ent.exampleSet.Add((i + 1).ToString());
                ent.exampleSet.Add((i - 1).ToString());
                ent.data = buf;
                table.AddNew(ent, EntityTrackingMode.KeepAttachedAfterSave);
                entL.Add(ent);
            }
            ents.SaveChanges(SaveChangesMode.Batch);

            var cnt = table.Count().Execute();

            Assert.Equal(RowsNo, cnt);

            var q = (from e in table select e.data).FirstOrDefault().Execute();

            for (int i = 0; i < 256; i++)
            {
                Assert.Equal(q[i], (byte)i);
            }


            foreach (var ent in entL)
            {
                table.Delete(ent);
            }

            ents.SaveChanges(SaveChangesMode.Batch);

            var cnt2 = table.Count().Execute();

            Assert.Equal(0, cnt2);
        }
コード例 #2
0
        public void Test1()
        {
            var table = ents.GetTable <Tweets>();

            int           RowsNo = 2000;
            List <Tweets> entL   = new List <Tweets>();

            for (int i = 0; i < RowsNo; i++)
            {
                var ent = new Tweets()
                {
                    tweet_id = Guid.NewGuid(), author = "test" + i.ToString(), body = "body" + i.ToString(), isok = (i % 2 == 0)
                };
                ent.exampleSet.Add(i.ToString());
                ent.exampleSet.Add((i + 1).ToString());
                ent.exampleSet.Add((i - 1).ToString());
                table.AddNew(ent, EntityTrackingMode.KeepAttachedAfterSave);
                entL.Add(ent);
            }
            ents.SaveChanges(SaveChangesMode.Batch);

            var cnt = table.Count().Execute();

            Assert.Equal(RowsNo, cnt);

            foreach (var ent in entL)
            {
                table.Delete(ent);
            }

            ents.SaveChanges(SaveChangesMode.Batch);

            var cnt2 = table.Count().Execute();

            Assert.Equal(0, cnt2);
        }