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)); } }
public async Task GetAsyncWithCustomObject() { var dapper = new DapperImplementor(SqlHelper.GetSqlGenerator()); using (var connection = await _fixture.Factory.ConnectionFactory.CreateAsync()) { var result = await dapper.GetAsync <TestEntity>(connection, new { Id = 1 }, null, null); Assert.NotNull(result); } }
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)); } }
public async Task InsertAndGetAsync() { var dapper = new DapperImplementor(SqlHelper.GetSqlGenerator()); using (var connection = await _fixture.Factory.ConnectionFactory.CreateAsync()) { dapper.Insert(connection, new List <TestEntity> { new TestEntity() }, null, null); var result = await dapper.GetAsync <TestEntity>(connection, 1, null, null); Assert.NotNull(result); Assert.Equal(1, result.Id); } }
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)); } }