Пример #1
0
        public void AddParameters_Example_Supplying_A_Parameter_Array_Of_DbParameters()
        {
            const string sql = @"
SELECT  *
FROM    SuperHero
WHERE   SuperHeroId = @SuperHeroId
        OR SuperHeroName = @SuperHeroName
        OR SuperHeroName LIKE '%@SuperHeroPartialName%'";

            DatabaseCommand databaseCommand = Sequelocity.GetDatabaseCommand(ConnectionStringsNames.SqlServerConnectionString);

            DbParameter superHeroIdParameter          = databaseCommand.CreateParameter("@SuperHeroId", 1, DbType.Int32);
            DbParameter superHeroNameParameter        = databaseCommand.CreateParameter("@SuperHeroName", "Superman", DbType.AnsiString);
            DbParameter superHeroPartialNameParameter = databaseCommand.CreateParameter("@SuperHeroPartialName", "S", DbType.AnsiString);

            List <SuperHero> superHeroes = Sequelocity.GetDatabaseCommand(ConnectionStringsNames.SqlServerConnectionString)
                                           .SetCommandText(sql)
                                           .AddParameters(superHeroIdParameter, superHeroNameParameter, superHeroPartialNameParameter)
                                           .ExecuteToList <SuperHero>();
        }