コード例 #1
0
        public void get_column_value()
        {
            var post = new Post()
            {
                Title = "title12"
            };
            var id = _db.Insert(post).InsertedId <int>();

            Assert.Equal("title12", _db.GetColumnValue <Post, string>(p => p.Title, p => p.Id == id));
            Assert.Null(_db.GetColumnValue <Post, string>(p => p.Title, p => p.Id == 2890));
        }
コード例 #2
0
        public override void ExecuteScalar(BenchmarksContainer bc)
        {
            bc.Add(id =>
            {
                _db.GetValue <string>("select title from sfposts where id=@0", 5);
            }, "SqlFu scalar");

            bc.Add(id =>
            {
                _db.GetColumnValue <sfPosts, string>(p => p.Title, p => p.Id == 5);
            }, "SqlFu get scalar expression based");

            //bc.Add(id =>
            //{
            //    _db.ExecuteScalar<int?>("select topicid from sfposts where id=@0 order by id", 5);
            //}, "SqlFu scalar null to nullable");
            //bc.Add(id =>
            //{
            //    _db.ExecuteScalar<PostType>("select Type from sfposts where id=@0 order by id", 5);
            //}, "SqlFu scalar enum");
        }