I have C# project for Windows Phone 8.1 with SQLite database.
Database contain a table, from which need select all data, and write it into array. Also have 2 classes: Links (like name of table) - contain description of table; Repository - class for methods.
I dont know how create method for inserting.
Begin like: using (var statement = SQLiteConnection.Prepare("SELECT _id, link FROM links WHERE _id=?")), but what next?
-
Which wrapper are you using?Fred– Fred2015-06-19 13:15:16 +00:00Commented Jun 19, 2015 at 13:15
-
Sorry, I dont understand what it isfeofan– feofan2015-06-19 13:30:15 +00:00Commented Jun 19, 2015 at 13:30
-
On Windows Phone you would normally use SQLite with a wrapper as some sort of abstraction layer: github.com/koush/sqlite-net / nuget.org/packages/SQLite.Net-PCL.Fred– Fred2015-06-19 15:01:12 +00:00Commented Jun 19, 2015 at 15:01
Add a comment
|
1 Answer
It's so simple.
Use class for description table (Linkes) to create new array(type). In other class create List method with query what you need.
public List <Linkses> Gettha()
{
List<Linkses> lin = new List<Linkses>();
using (var statement = con.Prepare("SELECT _id, link FROM links"))
{
while (statement.Step() == SQLiteResult.ROW)
{
Linkses link = new Linkses();
link.Id = (long)statement[0];
link.Linochka = (string)statement[1];
lin.Add(link);
}
}
return lin;
}
Then you must call that method with ToArray.
Linkses[] holla = App.repo.Gettha().ToArray();
1 Comment
Mostafiz Rahman
You will possibly get error if you try to type cast a
statement object to a long in this way: link.Id = (long)statement[0]; Rather use this way: Long.parseLong(statement[0].ToString())