SQLite ルートに行く場合は、SQLite.Net を見てください。既存のオブジェクトを保存し、コードをほとんど使用せずにロードします。
https://github.com/praeclarum/sqlite-net#readme
以下に例を示します。
// Add some extra atributes as needed to your existing class.
public class Stock
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
[MaxLength(8)]
public string Symbol { get; set; }
}
SQLite db 接続を作成し、Stock クラスのテーブルが存在することを確認します。
var db = new SQLiteConnection("foofoo");
db.CreateTable<Stock>();
Stock インスタンスを DB に追加します...例.保存してください!
public static void AddStock(SQLiteConnection db, string symbol) {
var s = db.Insert(new Stock() {
Symbol = symbol
});
Console.WriteLine("{0} == {1}", s.Symbol, s.Id);
}
DB から 1 つ以上の Stock(s) を取得します....
public static IEnumerable<Stock> QueryValuations (SQLiteConnection db, int stock)
{
return db.Query<Stock> ("select * from Stock where StockId = ?", Id);
}