public override void QueryTop10(BenchmarksContainer bc) { bc.Add(id => { _db.Query <sfPosts>("select top 10 * from sfposts where id>@0", 5); }, "SqlFu"); }
public void default_mapper() { var pv = _db.Query <PostViewModel>("select 1 as Id, 2 as Author_Id, 'test' as Author_Name,null as Topic").First(); Assert.Equal(1, pv.Id); Assert.Equal(2, pv.Author.Id); Assert.Equal("test", pv.Author.Name); Assert.Null(pv.Topic); }
public void query_list_param() { Config.EnsurePosts(); var list = new[] { 1, 2, 3 }; var all = _db.Query <Post>("select * from posts where Title=@1 or id in (@0)", list, "fer").ToArray(); Assert.Equal(3, all.Length); }
private void FillRealTableSchema(TableSchema table) { var columns = table.ModifiedColumns.AllColumnsNames; // var tableName = SqlServerProvider.FormatName(table.Name); var all = Db.Query <ColumnSchema>( @"select COLUMN_NAME as ColumnName, DATA_TYPE as DataType , cast (CHARACTER_MAXIMUM_LENGTH as varchar(5))as CharacterMaximumLength, cast (NUMERIC_PRECISION as varchar(5)) as NumericPrecision, cast (NUMERIC_SCALE as varchar(5)) as NumericScale, COLLATION_NAME as CollationName from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = @0 and COLUMN_NAME in (@1)", table.Name, columns); foreach (var cs in all) { var column = table.ModifiedColumns[cs.ColumnName]; column.Modifications.Current.Type = ExtractType(cs); column.Modifications.Current.Collation = cs.CollationName; } }
public void query() { Assert.Equal(5, _db.Query <Post>(P => P.CreatedOn.Year <= 2014 && P.Id <= 5).Count()); }