public int CreateScalarFunction(IDbHandle db, IScalarFunction sqliteFunction) { var internalDbHandle = (DbHandle)db; var funcCallbackExecutor = new FuncCallbackExecutor( sqliteFunction, SQLiteApiGenericInternal.GetAnsiString, SQLiteApiGenericInternal.sqlite3_result_int ); var func = new SQLiteApiGenericInternal.FuncCallback(funcCallbackExecutor.Execute); _allocatedGCHandles.Add(GCHandle.Alloc(func)); return(SQLiteApiGenericInternal.sqlite3_create_function( internalDbHandle.DbPtr, Encoding.UTF8.GetBytes(sqliteFunction.Name), sqliteFunction.ValueGetters.Length, SQLiteEncodings.SQLITE_UTF8, IntPtr.Zero, func, null, null)); }