Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var myDto = new MyDto {
                Id = 1, IsDeleted = true
            };

            Spry.Select <MyDto>().Column(_ => myDto.Id).Column(_ => myDto.IsDeleted).From("tt")
            .InnerJoin("table2", "audit").On("c1", "d1")
            .InnerJoin("table3", "audit").On("c2", "d2")
            .InnerJoin("table4", "audit").On("c4", "d2")
            .InSchema("review")
            .Where(_ => myDto.Id).EqualTo(1)
            .AndWhere(_ => myDto.Id).InBetween(1, 10)
            .AndWhere(_ => myDto.Id).GreaterThan(5)
            .Build();

            Spry.InsertInto("tableOne", "review")
            .Value("One", 1)
            .Value(_ => myDto.Id)
            .OutputIdentity()
            .Execute(null);

            Spry.Update("tableOne")
            .Set(_ => myDto.Id)
            .Where <int>("id").EqualTo(1)
            .Execute(null);

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public bool UpdateByName(string oldName, string name)
        {
            using (var connection = _connectionFactory.CreateConnection())
            {
                var rowsUpdated = Spry.Update <Customer>(CUSTOMER_TABLE)
                                  .Set(_ => name)
                                  .Where(_ => _.Name).EqualTo(oldName)
                                  .Execute(connection);

                return(rowsUpdated > 0);
            }
        }
Ejemplo n.º 3
0
        public bool Update(int customerId, string name, DateTime dateOfBirth)
        {
            using (var connection = _connectionFactory.CreateConnection())
            {
                var rowsUpdated = Spry.Update <Customer>(CUSTOMER_TABLE)
                                  .Set(_ => name)
                                  .Set(_ => dateOfBirth)
                                  .Where(_ => customerId).EqualTo(customerId)
                                  .Execute(connection);

                return(rowsUpdated > 0);
            }
        }
Ejemplo n.º 4
0
        public bool UpdateSqlInjection(int customerId, string name)
        {
            using (var connection = _connectionFactory.CreateConnection())
            {
                var rowsUpdated = Spry.Update <Customer>(CUSTOMER_TABLE)
                                  .Set(_ => name)
                                  .Where(_ => customerId).EqualTo(customerId)
                                  .AndWhere <int>("1 =1;" +
                                                  "DELETE FROM CUSTOMER; --").EqualTo(1)
                                  .Execute(connection);

                return(rowsUpdated > 0);
            }
        }