private List <ConceptApplication> LoadOldConceptApplicationsFromDatabase() { var previoslyAppliedConcepts = new List <ConceptApplication>(); _sqlExecuter.ExecuteReader( "SELECT ID, InfoType, ConceptInfoKey, ImplementationType, CreateQuery, RemoveQuery, ModificationOrder FROM Rhetos.AppliedConcept ORDER BY ModificationOrder", dataReader => { previoslyAppliedConcepts.Add(new ConceptApplication { Id = SqlUtility.ReadGuid(dataReader, 0), ConceptInfoTypeName = dataReader.GetString(1), ConceptInfoKey = dataReader.GetString(2), ConceptImplementationTypeName = dataReader.GetString(3), CreateQuery = SqlUtility.EmptyNullString(dataReader, 4), RemoveQuery = SqlUtility.EmptyNullString(dataReader, 5), OldCreationOrder = SqlUtility.ReadInt(dataReader, 6), DependsOn = null // It will be set later }); }); var invalidCa = previoslyAppliedConcepts.FirstOrDefault(ca => ca.ConceptInfoKey == ObsoleteConceptApplicationMark); if (invalidCa != null) { throw new FrameworkException($"Obsolete concept application loaded from database" + $" (Rhetos.ConceptApplication, ID = {SqlUtility.GuidToString(invalidCa.Id)})." + $" The update procedure for old version of the system should include deployment" + $" with empty DslScripts folder (using old version of Rhetos framework and packages)" + $" to remove old database structure and keep the data."); } return(previoslyAppliedConcepts); }
public void ExecuteSql_CaseInsenitive() { Console.WriteLine("NationalLanguage: " + SqlUtility.NationalLanguage); string table = GetRandomTableName(); var sqlExecuter = GetSqlExecuter(); sqlExecuter.ExecuteSql(new[] { "CREATE TABLE " + table + " ( S NVARCHAR2(256) )", "INSERT INTO " + table + " VALUES ('a')", "INSERT INTO " + table + " VALUES ('A')", "INSERT INTO " + table + " VALUES ('b')", "INSERT INTO " + table + " VALUES ('B')", }); var result = new List <string>(); sqlExecuter.ExecuteReader("SELECT * FROM " + table + " WHERE S LIKE 'a%'", reader => result.Add(SqlUtility.EmptyNullString(reader, 0))); Assert.AreEqual( TestUtility.DumpSorted(new[] { "a", "A" }), TestUtility.DumpSorted(result), "Comparison will be case insensitive depending on SqlUtility.NationalLanguage (see NLS_SORT), provided in connection string ProviderName (for example Rhetos.Oracle.GENERIC_M_CI or Rhetos.Oracle.XGERMAN_CI)."); result.Clear(); sqlExecuter = new OracleSqlExecuter(SqlUtility.ConnectionString, new ConsoleLogProvider(), new NullUserInfo()); sqlExecuter.ExecuteReader("SELECT * FROM " + table + " WHERE S LIKE 'a%'", reader => result.Add(SqlUtility.EmptyNullString(reader, 0))); Assert.AreEqual( TestUtility.DumpSorted(new[] { "a", "A" }), TestUtility.DumpSorted(result), "Using new instance of SqlExecuter."); }