public Entities() : base("name=Entities") { Environment.SetEnvironmentVariable("AppendManifestToken_SQLiteProviderManifest", ";BinaryGUID=True;"); SQLiteConnection Conn = (SQLiteConnection)Database.Connection; Conn.Open(); Conn.BindFunction(new DbGetRatingValueClass()); Conn.BindFunction(new DbCompareValuesClass()); //Database.Log = s => System.Diagnostics.Debug.WriteLine(s); //SQLiteCommand cm = new SQLiteCommand("SELECT MediaCategoryId FROM Media", Conn); //SQLiteDataReader dr = cm.ExecuteReader(); //while (dr.Read()) { // if (!dr.IsDBNull(0)) { // try { // string GuidString = dr.GetString(0); // Guid GuidValue = new Guid(GuidString); // SQLiteCommand Writer = new SQLiteCommand("UPDATE Media SET MediaCategoryId = @IdGuid WHERE MediaCategoryId = @IdString", Conn); // Writer.Parameters.Add("@IdGuid", System.Data.DbType.Guid).Value = GuidValue; // Writer.Parameters.Add("@IdString", System.Data.DbType.String).Value = GuidString; // Writer.ExecuteNonQuery(); // } // catch { } // } //} //throw new ApplicationException("Done"); }
private SQLiteConnection CreateConnection(string dbName) { SQLiteConnection conn = new SQLiteConnection($"Data Source={dbName};Version=3;UseUTF8Encoding=True;"); conn.Open(); SQLiteFunction function1 = new RegExSQLiteFunction(); var attributes1 = function1.GetType().GetCustomAttributes(typeof(SQLiteFunctionAttribute), true).Cast <SQLiteFunctionAttribute>().ToArray(); if (attributes1.Length == 0) { throw new InvalidOperationException("SQLiteFunction doesn't have SQLiteFunctionAttribute"); } conn.BindFunction(attributes1[0], function1); var function2 = new MaskSQLiteFunction(); var attributes2 = function2.GetType().GetCustomAttributes(typeof(SQLiteFunctionAttribute), true).Cast <SQLiteFunctionAttribute>().ToArray(); if (attributes2.Length == 0) { throw new InvalidOperationException("SQLiteFunction doesn't have SQLiteFunctionAttribute"); } conn.BindFunction(attributes2[0], function2); var function3 = new MySortSQLiteFunction(); var attributes3 = function3.GetType().GetCustomAttributes(typeof(SQLiteFunctionAttribute), true).Cast <SQLiteFunctionAttribute>().ToArray(); if (attributes3.Length == 0) { throw new InvalidOperationException("SQLiteFunction doesn't have SQLiteFunctionAttribute"); } conn.BindFunction(attributes3[0], function3); return(conn); }
public void OpenConnection() { if (_connection.State != ConnectionState.Open) { _connection.Open(); _connection.BindFunction(new RegExSQLiteFunction()); _connection.BindFunction(new DateTimeZoneConvertSQLiteFunction()); } }
public static void BindFunction(this SQLiteConnection connection, SQLiteFunction function) { var attributes = function.GetType().GetCustomAttributes(typeof(SQLiteFunctionAttribute), true).Cast <SQLiteFunctionAttribute>().ToArray(); if (attributes.Length <= 0) { throw new InvalidOperationException("SQLiteFunction doesn't have SQLiteFunctionAttribute"); } connection.BindFunction(attributes[0], function); }
/// <summary> /// Binds the given <paramref name="function"/> to the <paramref see="connection"/>. /// </summary> public void BindFunction(SQLiteFunctionBase function) { Ensure.NotNull(function, nameof(function)); Ensure.That <InvalidOperationException>(Connection.State == ConnectionState.Open, "Cannot bind a function to a closed."); var funcAttr = new SQLiteFunctionAttribute { Name = function.Name, FuncType = function.Type, Arguments = function.ArgumentCount }; Connection.BindFunction(funcAttr, function); }
public DatabaseManager(string FilePath) { string DatabaseSource = FilePath; GamesDB = new SQLiteConnection("Data Source=" + DatabaseSource + ";Version=3"); GamesDB.Open(); GamesDB.BindFunction( new SQLiteFunctionAttribute() { FuncType = FunctionType.Collation, Name = "library", }, new LibraryCollation() ); }
public static void BindSCFunctions(this SQLiteConnection connection) { //Static functions //Regex connection.BindFunction(new RegexIsMatchFunction()); connection.BindFunction(new RegexMatchFunction()); connection.BindFunction(new RegexNamedMatchFunction()); connection.BindFunction(new RegexReplaceFunction()); //String connection.BindFunction(new StringFormatFunction()); //Hash connection.BindFunction(new MD5Function()); connection.BindFunction(new SHA1Function()); connection.BindFunction(new SHA256Function()); connection.BindFunction(new SHA384Function()); connection.BindFunction(new SHA512Function()); //Path connection.BindFunction(new PathChangeExtensionFunction()); connection.BindFunction(new PathCombineFunction()); connection.BindFunction(new PathGetDirectoryNameFunction()); connection.BindFunction(new PathGetExtensionFunction()); connection.BindFunction(new PathGetFileNameFunction()); connection.BindFunction(new PathGetFileNameWithoutExtensionFunction()); //Random connection.BindFunction(new RandUniformFunction()); connection.BindFunction(new RandNormalFunction()); connection.BindFunction(new RandTriangularFunction()); //Math connection.BindFunction(new AcosFunction()); connection.BindFunction(new AsinFunction()); connection.BindFunction(new Atan2Function()); connection.BindFunction(new AtanFunction()); connection.BindFunction(new CeilingFunction()); connection.BindFunction(new CosFunction()); connection.BindFunction(new CoshFunction()); connection.BindFunction(new ExpFunction()); connection.BindFunction(new FloorFunction()); connection.BindFunction(new IEEERemainderFunction()); connection.BindFunction(new Log10Function()); connection.BindFunction(new LogFunction()); connection.BindFunction(new PowFunction()); connection.BindFunction(new SignFunction()); connection.BindFunction(new SinFunction()); connection.BindFunction(new SinhFunction()); connection.BindFunction(new SqrtFunction()); connection.BindFunction(new TanFunction()); connection.BindFunction(new TanhFunction()); connection.BindFunction(new TruncateFunction()); //Guid connection.BindFunction(new NewIdFunction()); //Archive connection.BindFunction(new CompressBytesFunction()); connection.BindFunction(new DecompressBytesFunction()); connection.BindFunction(new CompressTextFunction()); connection.BindFunction(new DecompressTextFunction()); //Collations connection.BindFunction(new LogicalCollationFunction()); connection.BindFunction(new LogicalCollationCIFunction()); //Aggregates connection.BindFunction(new GeometricMeanFunction()); connection.BindFunction(new HarmonicMeanFunction()); connection.BindFunction(new InterQuantileRangeFunction()); connection.BindFunction(new KurtosisFunction()); connection.BindFunction(new MedianFunction()); connection.BindFunction(new PopulationKurtosisFunction()); connection.BindFunction(new PopulationSkewnessFunction()); connection.BindFunction(new PopulationStdevFunction()); connection.BindFunction(new PopulationVarianceFunction()); connection.BindFunction(new QuantileFunction()); connection.BindFunction(new RootMeanSquareFunction()); connection.BindFunction(new SkewnessFunction()); connection.BindFunction(new StdevFunction()); connection.BindFunction(new VarianceFunction()); connection.BindFunction(new CovarianceFunction()); connection.BindFunction(new PearsonCorrelationFunction()); connection.BindFunction(new PopulationCovarianceFunction()); connection.BindFunction(new SpearmanCorrelationFunction()); }
public static void BindFunction(this SQLiteConnection connection, SQLiteFunction function) { var attr = function.GetType().GetCustomAttributes(typeof(SQLiteFunctionAttribute), false).FirstOrDefault() as SQLiteFunctionAttribute; connection.BindFunction(attr, function); }
public static void BindFunctions(this SQLiteConnection connection) { connection.BindFunction(new IUnicodeCollation()); connection.BindFunction(new NumericStringCollation()); connection.BindFunction(new UserLocaleCollation()); }