예제 #1
0
        public async Task Delete()
        {
            var dapper = new DapperImplementor(SqlHelper.GetSqlGenerator());

            using (var connection = await _fixture.Factory.ConnectionFactory.CreateAsync())
            {
                dapper.Delete(connection, new TestEntity()
                {
                    Id = 1
                }, null, null);
                Assert.Null(await dapper.GetAsync <TestEntity>(connection, 1, null, null));

                Assert.Throws <ArgumentException>(() => dapper.Delete(connection, new TestClass(), null, null));
            }
        }
예제 #2
0
        public async Task DeleteWithCustomObject()
        {
            var dapper = new DapperImplementor(SqlHelper.GetSqlGenerator());

            using (var connection = await _fixture.Factory.ConnectionFactory.CreateAsync())
            {
                dapper.Delete <TestEntity>(connection, new { Id = 1, Name = "1" }, null, null);
                Assert.Null(await dapper.GetAsync <TestEntity>(connection, 1, null, null));
            }
        }
예제 #3
0
        public async Task DeleteWithPredicate()
        {
            var dapper = new DapperImplementor(SqlHelper.GetSqlGenerator());

            using (var connection = await _fixture.Factory.ConnectionFactory.CreateAsync())
            {
                var predicate = new FieldPredicate <TestEntity>
                {
                    Operator     = Operator.Eq,
                    PropertyName = "Id",
                    Value        = 1
                };
                dapper.Delete <TestEntity>(connection, predicate, null, null);
                Assert.Null(await dapper.GetAsync <TestEntity>(connection, 1, null, null));
            }
        }