public static void SaveObject(string persistenceId, string persistenceContext, string objectContent) { try { using (var db = new LiteDatabase(__peristenceDbPath)) { var obj = GetObjects <PersistedObject>(db); var qry = GetQuery(persistenceId, persistenceContext); var po = obj.Find(qry).FirstOrDefault(); if (po == null) { po = new PersistedObject { PersistenceId = persistenceId, PersistenceContext = persistenceContext, Content = objectContent }; obj.Insert(po); } else { po.Content = objectContent; obj.Update(po); } } } catch (Exception ex) { OP_Logger.LogException(ex); } }
public static void DeleteObject(string persistenceId, string persistenceContext) { try { using (var db = new LiteDatabase(__peristenceDbPath)) { var obj = GetObjects <PersistedObject>(db); var qry = GetQuery(persistenceId, persistenceContext); obj.Delete(qry); } } catch (Exception ex) { OP_Logger.LogException(ex); } }
public static string ReadObject(string persistenceId, string persistenceContext) { try { using (var db = new LiteDatabase(__peristenceDbPath)) { var obj = GetObjects <PersistedObject>(db); var qry = GetQuery(persistenceId, persistenceContext); var cnt = obj.Find(qry).Select(p => p.Content).FirstOrDefault(); return(cnt); } } catch (Exception ex) { OP_Logger.LogException(ex); } return(null); }