Esempio n. 1
0
        public void update_table_poco()
        {
            var rez = _db.Update <Post>(new { Title = "alt title", TopicId = 3, Id = 2 });

            Assert.Equal(1, rez);
            var p = _db.Get <Post>(2);

            Assert.Equal("alt title", p.Title);
            Assert.Equal(3, p.TopicId);
        }
Esempio n. 2
0
        public void get_entity_by_criteria()
        {
            var post = new Post()
            {
                Title = "title12"
            };
            var id  = _db.Insert(post).InsertedId <int>();
            var ent = _db.Get <Post>(p => p.Id == id);

            Assert.Equal("title12", ent.Title);

            ent = _db.Get <Post>(p => p.Id == 280);
            Assert.Null(ent);
        }
Esempio n. 3
0
 public override void FetchSingleEntity(BenchmarksContainer bc)
 {
     bc.Add(id =>
     {
         _db.Get <sfPosts>(5);
     }, "SqlFu Get");
     bc.Add(id =>
     {
         _db.QuerySingle <sfPosts>("select * from sfPosts where id=@0", 5);
     }, "SqlFu FirstOrDefault");
 }
Esempio n. 4
0
 private void GenerateSql()
 {
     for (var i = 0; i < 1; i++)
     {
         //var builder = new ExpressionSqlBuilder<Pool>(db.GetProvider().BuilderHelper);
         //builder
         //    .WriteSelect()
         //    .WriteSelectAllColumns()
         //    .WriteFrom()
         //    .Where(d=>d.Id==i);
         // Console.WriteLine(builder.ToString());
         _db.Get <Pool>(d => d.Id == i);
     }
 }