Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the last of tables #376

Open
Robofolk opened this issue Feb 12, 2018 · 0 comments
Open

How to get the last of tables #376

Robofolk opened this issue Feb 12, 2018 · 0 comments

Comments

@Robofolk
Copy link

I tried to get the list of tables in a database, but it throws an exception?

private SQLiteAsyncConnection _connetion;
public async Task < List < string > > GetAllTablesAsync()
{
string queryString = $"SELECT * FROM sqlite_master WHERE type = 'table'";
return await _connection.QueryAsync < string > (queryString).ConfigureAwait(false);
}

However if use QueryAsync < object > instead, what I get is a list of 'System.Object', which give me no more information (like table name, etc.)! I must be doing the casting wrong. What generic type do I need to pass in for QueryAsync<?> ?

System.MissingMethodException: Constructor on type 'System.String' not found. at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x00213] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/rttype.cs:5419 at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x000ae] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/activator.cs:107 at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/activator.cs:112 at SQLite.Net.ContractResolver.CreateObject (System.Type type, System.Object[] constructorArgs) [0x0001c] in <8f2bb39aeff94a30a8628064be9c7efe>:0 at SQLite.Net.SQLiteCommand+<ExecuteDeferredQuery>d__151[T].MoveNext () [0x000e2] in <8f2bb39aeff94a30a8628064be9c7efe>:0
at System.Collections.Generic.List1[T]..ctor (System.Collections.Generic.IEnumerable1[T] collection) [0x00077] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/collections/generic/list.cs:99
at System.Linq.Enumerable.ToList[TSource] (System.Collections.Generic.IEnumerable1[T] source) [0x00015] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/external/corefx/src/System.Linq/src/System/Linq/ToCollection.cs:30 at SQLite.Net.SQLiteCommand.ExecuteQuery[T] () [0x0001c] in <8f2bb39aeff94a30a8628064be9c7efe>:0 at SQLite.Net.SQLiteConnection.Query[T] (System.String query, System.Object[] args) [0x00008] in <8f2bb39aeff94a30a8628064be9c7efe>:0 at SQLite.Net.Async.SQLiteAsyncConnection+<>c__DisplayClass38_01[T].b__0 () [0x00029] in <563d605f9f014eeeb32fd4a27b4d142e>:0
at System.Threading.Tasks.Task1[TResult].InnerInvoke () [0x0000f] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Future.cs:680 at System.Threading.Tasks.Task.Execute () [0x00010] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/threading/Tasks/Task.cs:2502 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Users/builder/data/lanes/4992/mono-mac-sdk/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at MyApp.Data.SqliteDatabaseService+d__7.MoveNext () [0x000e2] in /Users/xxxxx/Projects/ClubInfo/ClubInfo.Data/ORM/SqliteDatabaseService.cs:51`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant