public void ExecuteReaderDynamic() { var rs = DbExecutor.ExecuteReaderDynamic(connectionFactory(), "select * from Methods where TypeId = @TypeId", new { TypeId = 2 }) .Select(d => new Method { Name = d.Name, MethodId = d.MethodId, }) .ToArray(); rs.Length.Is(3); rs.Select(x => x.Name).Is("StartsWith", "EndsWith", "Contains"); using (var exec = new DbExecutor(connectionFactory())) { var ri = exec.ExecuteReaderDynamic("select * from Methods where TypeId = @TypeId", new { TypeId = 2 }) .Select(d => new Method { Name = d.Name, MethodId = d.MethodId, }) .ToArray(); ri.Length.Is(3); ri.Select(x => x.Name).Is("StartsWith", "EndsWith", "Contains"); } }
public void ExecuteReaderDynamic() { var rs = DbExecutor.ExecuteReaderDynamic(connectionFactory(), "select * from sqlite_master where type = @TypeId", new { TypeId = "table" }) .Select(d => { var x = new SqliteMaster(); x.name = (string)d.name; x.rootpage = (int)d.rootpage; x.sql = (string)d.sql; x.tbl_name = (string)d.tbl_name; x.type = (string)d.type; return(x); }) .ToArray(); rs.Length.Is(6); rs.Select(x => x.name).Is("employees", "departments", "dept_emp", "dept_manager", "titles", "salaries"); using (var exec = new DbExecutor(connectionFactory())) { var ri = exec.ExecuteReaderDynamic("select * from sqlite_master where type = @TypeId", new { TypeId = "table" }) .Select(d => { var x = new SqliteMaster(); x.name = (string)d.name; x.rootpage = (int)d.rootpage; x.sql = (string)d.sql; x.tbl_name = (string)d.tbl_name; x.type = (string)d.type; return(x); }) .ToArray(); ri.Length.Is(6); rs.Select(x => x.name).Is("employees", "departments", "dept_emp", "dept_manager", "titles", "salaries"); } }