c# - Creating tables with the SQLite-net library -
i'm researching sqlite - .net (https://github.com/praeclarum/sqlite-net) in order add local storage project.
i've come few questions:
the tables created per model, , in order create tables code should used:
var db = new sqliteconnection("foofoo"); db.createtable<stock>(); db.createtable<valuation>();the problem is, in mvvm approach, written? thought bootstrapper.cs i'm not quite sure how effective is.
in 1 of examples, example code of model:
public class valuation { [primarykey, autoincrement] public int id { get; set; } [indexed] public int stockid { get; set; } public datetime time { get; set; } public decimal price { get; set; } }does
[indexed]statement apply onlystockid, or 3stockid,time,price?
data service! create dataservice class. pass path database or config. have constructor create sqliteconnection, create tables, add default data.
if using ioc container can register dataservice use in viewmodels. consider registering create immediate flag set true database gets initialized right away.
sorry don't have working example @ moment.
Comments
Post a Comment