static readonly string s_systemDir = "JsonExportImport"; // appended to SessionBase.BaseDatabasePath static void Main(string[] args) { try { int personCt = 0; using (SessionBase session = new SessionNoServer(s_systemDirToImport)) { session.BeginRead(); IEnumerable <string> personStringEnum = session.ExportToJson <Person>(); using (SessionBase sessionImport = new SessionNoServer(s_systemDir)) { sessionImport.BeginUpdate(); foreach (string json in personStringEnum) { Person person = sessionImport.ImportJson <Person>(json); sessionImport.Persist(person); personCt++; } session.Commit(); sessionImport.Commit(); Console.WriteLine("Imported " + personCt + " from Json strings"); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
static readonly string s_systemDir = "JsonExportImport"; // appended to SessionBase.BaseDatabasePath static void Main(string[] args) { try { int personCt = 0; using (SessionBase session = new SessionNoServer(s_systemDirToImport)) { session.BeginRead(); IEnumerable<string> personStringEnum = session.ExportToJson<Person>(); using (SessionBase sessionImport = new SessionNoServer(s_systemDir)) { sessionImport.BeginUpdate(); foreach (string json in personStringEnum) { Person person = sessionImport.ImportJson<Person>(json); sessionImport.Persist(person); personCt++; } session.Commit(); sessionImport.Commit(); Console.WriteLine("Imported " + personCt + " from Json strings"); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
/// <summary> /// Get the names of all persitent types used. /// </summary> /// <param name="path">Path to database directory on server relativer to server setting <see cref="SessionBase.BaseDatabasePath"/></param> /// <returns>All type names registered in the database schema</returns> public IEnumerable<string> Get(string path) { using (SessionNoServer session = new SessionNoServer(path)) { session.BeginRead(); Database db = session.OpenDatabase(1); var e = db.AllObjects<VelocityDbType>(false); var types = session.ExportToJson<VelocityDbType>(false, false); List<string> stringList = new List<String>(); foreach (VelocityDbType t in e) yield return t.Type.ToGenericTypeString(); session.Commit(); } }
/// <summary> /// Get the names of all persitent types used. /// </summary> /// <param name="path">Path to database directory on server relativer to server setting <see cref="SessionBase.BaseDatabasePath"/></param> /// <returns>All type names registered in the database schema</returns> public IEnumerable <string> Get(string path) { using (SessionNoServer session = new SessionNoServer(path)) { session.BeginRead(); Database db = session.OpenDatabase(1); var e = db.AllObjects <VelocityDbType>(false); var types = session.ExportToJson <VelocityDbType>(false, false); List <string> stringList = new List <String>(); foreach (VelocityDbType t in e) { yield return(t.Type.ToGenericTypeString()); } session.Commit(); } }