public static void populateWithDebugData(iSerializerSession sess) { var curTest = sess.Cursor <FiltersTest>(); using (var trans = sess.BeginTransaction()) { curTest.AddRange(debugData()); trans.Commit(); } }
void InitFoldersView() { tree.Nodes.Clear(); m_dictNodes.Clear(); using (var trans = sess.BeginTransaction()) { // Add the root node rs.filterFindEqual("id", EFS.idRootFolder); var eRoot = rs.getFirst(); nodeRoot = newNode(eRoot); tree.Nodes.Add(nodeRoot); // Add the fake child, foe the "+" to show up nodeRoot.Nodes.Add(getFakeNode()); } }
static void PopulateDemoDatabase(iSerializerSession sess) { Person[] personsTest = new Person[] { new Person(Person.eSex.Female, "Jenifer Smith", new string[0]), new Person(Person.eSex.Male, "Konstantin", new string[] { "+7 926 139 63 18" }), new Person(Person.eSex.Male, "John Smith", new string[] { "+1 800 123 4567", "+1 800 123 4568" }), new Person(Person.eSex.Female, "Mary Jane", new string[] { "555-1212" }), new Person(Person.eSex.Other, "Microsoft", new string[] { "+1 800 642 7676", "1-800-892-5234" }), }; Cursor <Person> curPerson = sess.Cursor <Person>(); using (var trans = sess.BeginTransaction()) { curPerson.AddRange(personsTest); trans.Commit(); } }
// Try to read record bu calling ReadRecord delegate. // If it returns false = no more records. // Then add a record by calling StoreRecord delegate. // If it returns false = the record was not added and the update should be discarded. protected int ImportData(Func <int, bool> ReadRecord, Func <int, bool> StoreRecord) { int iRecordsCounter = 0; using (var t = sess.BeginTransaction()) { // Clean up the whole destination table. while (Api.TryMoveLast(sess.idSession, idTable)) { Api.JetDelete(sess.idSession, idTable); } // Import the records while (true) { if (!ReadRecord(iRecordsCounter)) { break; } using (Update update = new Update(sess.idSession, idTable, JET_prep.Insert)) { if (StoreRecord(iRecordsCounter)) { update.Save(); iRecordsCounter++; if (0 == (iRecordsCounter % 64)) { t.LazyCommitAndReopen(); } } else { update.Cancel(); } } } t.Commit(); // serializer.tableAttribute.onTableChanged( this, new NotifyTableChangedArgs( NotifyTableChangedAction.Reset ) ); return(iRecordsCounter); } }
static void RunTests(iSerializerSession sess) { var rs = sess.Recordset <Person>(); using (var trans = sess.BeginTransaction()) { Console.WriteLine("Total count: {0}", rs.Count()); Console.WriteLine("Sorted by sex:"); PrintPersons(rs.orderBy(p => p.sex)); Console.WriteLine("Males:"); PrintPersons(rs.where (p => Person.eSex.Male == p.sex)); Console.WriteLine(@"Names containing ""Smith"":"); PrintPersons(rs.where (p => p.name.Contains("Smith"))); Console.WriteLine("Phone"); PrintPersons(rs.where (p => Queries.Contains(p.phones, "+1 800 642 7676"))); // The equivalent: // PrintPersons( rs.where( p => p.phones.Contains( "+1 800 642 7676" ) ) ); } }