I am using System.Data.SQLite.Core nuget package in my asp.net core 3 app.
I have a SQLite DB with my table, assuming something like this:
+-----+------------+-----+
| ... | Phone | ... |
+-----+------------+-----+
| --- | 0123456789 | --- |
+-----+------------+-----+
| --- | 9876543210 | --- |
+-----+------------+-----+
I do a simple query
command = new SQLiteCommand("SELECT * FROM Table", connection);
var reader = await command.ExecuteReaderAsync();
and get data in my reader. But when I try to Istance the values in an object I can read and cast every value to its type, however I can't cast the phone value into a string (I have declared it as a string in my DB), I mean I can cast it using explicit cast
var p = reader[index2];
var t = p.GetType().Name; //--> String
var myobj = new MyObj(othervalues: reader.GetString(index1), phone: (string)reader[index2]);
That is working but why can't I simply do this ?
... phone: reader.GetString(index2)...
And there is a way to do it ?
Thanks for your answer!
Update:

'0215556545'then when i read it usingGetInt64(index)i will get215556545