public void TestSqLiteConnectionUpdateViaTableNameViaQueryGroup() { using (var connection = new SqliteConnection(Database.ConnectionString)) { // Setup var table = Database.CreateCompleteTables(1, connection).First(); var queryFields = new[] { new QueryField("Id", table.Id), new QueryField("ColumnInt", table.ColumnInt) }; var queryGroup = new QueryGroup(queryFields); Helper.UpdateCompleteTableProperties(table); // Act var result = DbConnectionExtension.Update(connection, ClassMappedNameCache.Get <CompleteTable>(), table, queryGroup); // Assert Assert.AreEqual(1, result); // Act var queryResult = connection.Query(ClassMappedNameCache.Get <CompleteTable>(), table.Id).First(); // Assert Helper.AssertPropertiesEquality(table, queryResult); } }
public void TestSqLiteConnectionUpdateViaTableNameViaDynamic() { using (var connection = new SqliteConnection(Database.ConnectionString)) { // Setup var table = Database.CreateCompleteTables(1, connection).First(); Helper.UpdateCompleteTableProperties(table); // Act var result = DbConnectionExtension.Update(connection, ClassMappedNameCache.Get <CompleteTable>(), table, new { table.Id }); // Assert Assert.AreEqual(1, result); // Act var queryResult = connection.Query(ClassMappedNameCache.Get <CompleteTable>(), table.Id).First(); // Assert Helper.AssertPropertiesEquality(table, queryResult); } }
public void TestSqLiteConnectionUpdateViaTableNameAsExpandoObjectViaDataEntity() { using (var connection = new SqliteConnection(Database.ConnectionStringMDS)) { // Setup Database.CreateMdsCompleteTables(1, connection).First(); var table = Helper.CreateMdsCompleteTablesAsExpandoObjects(1).First(); // Act var result = DbConnectionExtension.Update(connection, ClassMappedNameCache.Get <MdsCompleteTable>(), table); // Assert Assert.AreEqual(1, result); // Act var queryResult = connection.Query(ClassMappedNameCache.Get <MdsCompleteTable>(), result).First(); // Assert Helper.AssertMembersEquality(queryResult, table); } }
public void TestPostgreSqlConnectionUpdateViaTableNameViaQueryField() { // Setup var table = Database.CreateCompleteTables(1).First(); using (var connection = new NpgsqlConnection(Database.ConnectionString)) { // Setup Helper.UpdateCompleteTableProperties(table); // Act var result = DbConnectionExtension.Update(connection, ClassMappedNameCache.Get <CompleteTable>(), table, new QueryField("Id", table.Id)); // Assert Assert.AreEqual(1, result); // Act var queryResult = connection.Query <CompleteTable>(table.Id).First(); // Assert Helper.AssertPropertiesEquality(table, queryResult); } }