public static void Initialize() { Assembly assembly = null; try { assembly = Assembly.Load(new AssemblyName("SQLitePCLRaw.batteries_v2")); } catch { } if (assembly != null) { assembly.GetType("SQLitePCL.Batteries_V2").GetTypeInfo().GetDeclaredMethod("Init") .Invoke(null, null); } if (ApplicationDataHelper.CurrentApplicationData != null) { var rc = sqlite3_win32_set_directory( SQLITE_WIN32_DATA_DIRECTORY_TYPE, ApplicationDataHelper.LocalFolderPath); SqliteException.ThrowExceptionForRC(rc, db: null); rc = sqlite3_win32_set_directory( SQLITE_WIN32_TEMP_DIRECTORY_TYPE, ApplicationDataHelper.TemporaryFolderPath); SqliteException.ThrowExceptionForRC(rc, db: null); } }
public static void Initialize() { Assembly assembly = null; try { assembly = Assembly.Load(new AssemblyName("SQLitePCLRaw.batteries_v2")); } catch { } if (assembly != null) { assembly.GetType("SQLitePCL.Batteries_V2").GetTypeInfo().GetDeclaredMethod("Init") .Invoke(null, null); } if ((!AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue19754", out var isEnabled) || !isEnabled) && ApplicationDataHelper.CurrentApplicationData != null) { var rc = sqlite3_win32_set_directory( SQLITE_WIN32_DATA_DIRECTORY_TYPE, ApplicationDataHelper.LocalFolderPath); SqliteException.ThrowExceptionForRC(rc, db: null); rc = sqlite3_win32_set_directory( SQLITE_WIN32_TEMP_DIRECTORY_TYPE, ApplicationDataHelper.TemporaryFolderPath); SqliteException.ThrowExceptionForRC(rc, db: null); } }
private void GetColumns(DbConnection connection, DatabaseTable table) { using var command = connection.CreateCommand(); command.CommandText = new StringBuilder() .AppendLine("SELECT \"name\", \"type\", \"notnull\", \"dflt_value\"") .AppendLine("FROM pragma_table_info(@table)") .AppendLine("ORDER BY \"cid\";") .ToString(); var parameter = command.CreateParameter(); parameter.ParameterName = "@table"; parameter.Value = table.Name; command.Parameters.Add(parameter); using var reader = command.ExecuteReader(); while (reader.Read()) { var columnName = reader.GetString(0); var dataType = reader.GetString(1); var notNull = reader.GetBoolean(2); var defaultValue = !reader.IsDBNull(3) ? FilterClrDefaults(dataType, notNull, reader.GetString(3)) : null; _logger.ColumnFound(table.Name, columnName, dataType, notNull, defaultValue); var autoIncrement = 0; if (connection is SqliteConnection sqliteConnection && !(table is DatabaseView)) { var db = sqliteConnection.Handle; var rc = sqlite3_table_column_metadata( db, connection.Database, table.Name, columnName, out var _, out var _, out var _, out var _, out autoIncrement); SqliteException.ThrowExceptionForRC(rc, db); } table.Columns.Add(new DatabaseColumn { Table = table, Name = columnName, StoreType = dataType, IsNullable = !notNull, DefaultValueSql = defaultValue, ValueGenerated = autoIncrement != 0 ? ValueGenerated.OnAdd : default(ValueGenerated?) }); } }
public CommitFailedException(Database db, int rc) : base(GetMessage(db, rc), rc, rc) { SqliteException.ThrowExceptionForRC(SQLitePCL.raw.SQLITE_ABORT, db.Connection.Handle); }