public static WindowsPersistence factory(String name) { WindowsPersistence obj = WindowsPersistence.findByName(name); if (obj == null) { obj = new WindowsPersistence(); obj.name = name; } return(obj); }
public static WindowsPersistence findByName(String name) { using (LiteDatabase db = WindowsPersistence.getDB()) { // Get customer collection var col = db.GetCollection <WindowsPersistence>(TABLE); var results = col.Find(x => x.name == name); WindowsPersistence tmp = null; foreach (WindowsPersistence result in results) { tmp = result; } return(tmp); } }
public void save() { using (LiteDatabase db = WindowsPersistence.getDB()) { // Get customer collection var col = db.GetCollection <WindowsPersistence>(TABLE); if (WindowsPersistence.findByName(this.name) == null) { col.Insert(this); } else { col.Update(this); } col.EnsureIndex(x => x.name, true); } }