Пример #1
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));
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
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));
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
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));
            }
        }