Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ASP.NET Database path
- var path = Server.MapPath("~/App_Data/site.db");
- using (var db = new LiteDatabase(path))
- {
- //Sets or Creates a Table in DB
- var bottles = db.GetCollection<Bottle>("Bottles");
- //Creates a new bottle object and saves in db
- var bottle = new Bottle
- {
- Name = "Something",
- Price = 600
- };
- bottles.Insert(bottle);
- //Get all the bottles to list
- List<Bottle> _list = bottles.FindAll().ToList();
- //Get a bottle by Id and update it
- Bottle _bottle = bottles.FindOne(b => b.Id == 4);
- _bottle.Name = "Kettle One";
- bottles.Update(_bottle);
- //Delete by Id
- bottles.Delete(b=>b.Id == 4);
Add Comment
Please, Sign In to add comment