예제 #1
0
        public void TestSqLiteConnectionDeleteAllAsyncViaPrimaryKeys()
        {
            using (var connection = new SqliteConnection(Database.ConnectionString))
            {
                // Setup
                var tables      = Database.CreateCompleteTables(10, connection);
                var primaryKeys = ClassExpression.GetEntitiesPropertyValues <CompleteTable, object>(tables, e => e.Id);

                // Act
                var result = connection.DeleteAllAsync <CompleteTable>(primaryKeys).Result;

                // Assert
                Assert.AreEqual(tables.Count(), result);
            }
        }
예제 #2
0
        public void TestMySqlConnectionDeleteAllViaPrimaryKeysBeyondLimits()
        {
            // Setup
            var tables      = Database.CreateCompleteTables(5000);
            var primaryKeys = ClassExpression.GetEntitiesPropertyValues <CompleteTable, object>(tables, e => e.Id);

            using (var connection = new MySqlConnection(Database.ConnectionString).EnsureOpen())
            {
                // Act
                var result = connection.DeleteAll <CompleteTable>(primaryKeys);

                // Assert
                Assert.AreEqual(tables.Count(), result);
            }
        }
예제 #3
0
        public void TestMySqlConnectionDeleteAllAsyncViaTableNameViaPrimaryKeys()
        {
            // Setup
            var tables      = Database.CreateCompleteTables(10);
            var primaryKeys = ClassExpression.GetEntitiesPropertyValues <CompleteTable, object>(tables, e => e.Id);

            using (var connection = new MySqlConnection(Database.ConnectionString).EnsureOpen())
            {
                // Act
                var result = connection.DeleteAllAsync(ClassMappedNameCache.Get <CompleteTable>(), primaryKeys).Result;

                // Assert
                Assert.AreEqual(tables.Count(), result);
            }
        }
예제 #4
0
        public void TestSqLiteConnectionDeleteAllViaTableNameViaPrimaryKeys()
        {
            using (var connection = new SqliteConnection(Database.ConnectionStringMDS))
            {
                // Setup
                var tables      = Database.CreateMdsCompleteTables(10, connection);
                var primaryKeys = ClassExpression.GetEntitiesPropertyValues <MdsCompleteTable, object>(tables, e => e.Id);

                // Act
                var result = connection.DeleteAll(ClassMappedNameCache.Get <MdsCompleteTable>(), primaryKeys);

                // Assert
                Assert.AreEqual(tables.Count(), result);
            }
        }
예제 #5
0
        public void TestClassExpressionGetEntitiesPropertyValuesViaField()
        {
            // Setup
            var entities = GetEntities(10).AsList();

            // Act
            var propertyValues = ClassExpression.GetEntitiesPropertyValues <ClassExpressionTestClass, string>(entities, new Field("Property1"));

            // Assert
            Assert.AreEqual(entities.Count(), propertyValues.Count());
            for (var i = 0; i < entities.Count(); i++)
            {
                var entity = entities.ElementAt(i);
                Assert.AreEqual(entity.Property1, propertyValues.ElementAt(i));
            }
        }
예제 #6
0
        public void TestSqlConnectionDeleteAllForInheritedViaPrimary()
        {
            // Setup
            var entities = Helper.CreateInheritedIdentityTables(10);

            using (var connection = new SqlConnection(Database.ConnectionStringForRepoDb))
            {
                // Act
                connection.InsertAll <InheritedIdentityTable>(entities);

                // Act
                var deleteResult = connection.DeleteAll <InheritedIdentityTable>(
                    ClassExpression.GetEntitiesPropertyValues <InheritedIdentityTable, object>(entities, "Id"));

                // Assert
                Assert.AreEqual(entities.Count(), deleteResult);
                Assert.AreEqual(0, connection.CountAll <InheritedIdentityTable>());
            }
        }