public void ModelInfo() { ModelInfo model = new ModelInfo(); BomTable bt = new BomTable() { BomName = Guid.NewGuid().ToString(), Header = new List <string>() { Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), Guid.NewGuid().ToString() }, TotalCols = 2, TotalRow = 10, //Rows = new List<BomTableRow>() }; //for (int i = 0; i < 10; i++) //{ // BomTableRow row = new BomTableRow(); // //for (int j = 0; j < 10; j++) // //{ // // row.Cells.Add("Value " + j.ToString()); // //} // bt.Rows.Add(row); //} model.BomTables = new List <BomTable>(); model.BomTables.Add(bt); try { using (SessionNoServerShared session = new SessionNoServerShared(s_systemDir)) { session.BeginUpdate(); //session.Persist(model.BomTables); session.Persist(model); session.Commit(); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); } try { using (SessionNoServerShared session = new SessionNoServerShared(s_systemDir)) { session.BeginRead(); //var models1 = session.AllObjects<List<BomTable>>().ToList(); var models = session.AllObjects <ModelInfo>().ToList(); session.Commit(); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.ToString()); } }
public void LocalDateTest() { LocalDate d1 = new LocalDate(2016, 1, 10); LocalDate d2 = new LocalDate(2016, 1, 1); LocalDate d1other = new LocalDate(2016, 1, 10); Assert.AreNotEqual(d1, d2); Assert.AreEqual(d1, d1other); using (SessionNoServer session = new SessionNoServer(systemDir)) { session.BeginUpdate(); LocalDateField test1 = new LocalDateField("def", d1); session.Persist(test1); LocalDateField test = new LocalDateField("abc", d2); session.Persist(test); var result1 = session.AllObjects <LocalDateField>().First(t => t.Field2.Equals(d2)); // this works session.Commit(); } using (var session = new SessionNoServerShared(systemDir)) { session.BeginRead(); var result2 = session.AllObjects <LocalDateField>().First(t => { var l = t.Field2; return(l.Equals(d2)); }); // this should work and doesnt session.Commit(); } }
public void Create4Projects(int numberOfProjects) { Project project = null; Project priorProject = null; for (int i = 0; i < numberOfProjects; i++) { using (var session = new SessionNoServerShared(systemDir)) { session.BeginUpdate(); IssueTracker issueTracker = session.AllObjects <IssueTracker>(false).FirstOrDefault(); User user = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Keys.Count - 1)]; string p = "project" + i.ToString(); string d = "pdescription" + i.ToString(); project = new Project(user, p, d); session.Persist(project); priorProject = project; issueTracker.ProjectSet.Add(project); session.Commit(); } } }