当前位置: 首页>>代码示例>>C#>>正文


C# SessionNoServer.Commit方法代码示例

本文整理汇总了C#中SessionNoServer.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# SessionNoServer.Commit方法的具体用法?C# SessionNoServer.Commit怎么用?C# SessionNoServer.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SessionNoServer的用法示例。


在下文中一共展示了SessionNoServer.Commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: aaaFakeLicenseDatabase

 public void aaaFakeLicenseDatabase()
 {
   Assert.Throws<NoValidVelocityDBLicenseFoundException>(() =>
   {
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
       session.BeginUpdate();
       Database database;
       License license = new License("Mats", 1, null, null, null, 99999, DateTime.MaxValue, 9999, 99, 9999);
       Placement placer = new Placement(License.PlaceInDatabase, 1, 1, 1);
       license.Persist(placer, session);
       for (uint i = 10; i < 20; i++)
       {
         database = session.NewDatabase(i);
         Assert.NotNull(database);
       }
       session.Commit();
       File.Copy(Path.Combine(systemDir, "20.odb"), Path.Combine(systemDir, "4.odb"));
       session.BeginUpdate();
       for (uint i = 21; i < 30; i++)
       {
         database = session.NewDatabase(i);
         Assert.NotNull(database);
       }
       session.RegisterClass(typeof(VelocityDbSchema.Samples.Sample1.Person));
       Graph g = new Graph(session);
       session.Persist(g);
       session.Commit();
     }
   });
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:31,代码来源:ADatabaseIteration.cs

示例2: TwoUpdaters1

 public void TwoUpdaters1()
 {
   UInt64 id;
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     Man man = new Man();
     man.Persist(session, man);
     id = man.Id;
     session.Commit();
     session.BeginUpdate();
     man.Age = ++man.Age;
     Database db = session.NewDatabase(3567);
     using (SessionNoServer session2 = new SessionNoServer(systemDir))
     {
       session2.BeginUpdate();
       Man man2 = (Man)session2.Open(id);
       Assert.Less(man2.Age, man.Age);
       man2.Age = ++man.Age;
       session2.Commit();
     }
     session.DeleteDatabase(db);
     session.Commit(); // OptimisticLockingFailed here
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:25,代码来源:MultipleUpdaters.cs

示例3: Main

    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());
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:31,代码来源:JsonExportImport.cs

示例4: CreateLocationSameHost

 public void CreateLocationSameHost()
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     DatabaseLocation remoteLocation = new DatabaseLocation(Dns.GetHostName(), location2Dir, locationStartDbNum, locationEndDbNum, session, PageInfo.compressionKind.LZ4, 0);
     remoteLocation = session.NewLocation(remoteLocation);
     Database database = session.NewDatabase(remoteLocation.StartDatabaseNumber);
     Assert.NotNull(database);
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     Database database = session.OpenDatabase(locationStartDbNum, false);
     Assert.NotNull(database);
     session.DeleteDatabase(database);
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     foreach (DatabaseLocation loc in session.DatabaseLocations)
       Console.WriteLine(loc.ToStringDetails(session, false));
     session.DeleteLocation(session.DatabaseLocations.LocationForDb(locationStartDbNum));
     foreach (DatabaseLocation loc in session.DatabaseLocations)
       Console.WriteLine(loc.ToStringDetails(session, false));
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:30,代码来源:DatabaseLocationTest.cs

示例5: LocalDateTest

    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 (SessionNoServer session = new SessionNoServer(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();
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:30,代码来源:DateTimeTest.cs

示例6: Main

    static readonly string systemDir = "Sample3"; // appended to SessionBase.BaseDatabasePath

    static void Main(string[] args)
    {
      try
      {
        using (SessionNoServer session = new SessionNoServer(systemDir))
        {
          Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
          session.BeginUpdate();
          Person robinHood = new Person("Robin", "Hood", 30);
          Person billGates = new Person("Bill", "Gates", 56, robinHood);
          Person steveJobs = new Person("Steve", "Jobs", 56, billGates);
          robinHood.BestFriend = billGates;
          session.Persist(steveJobs);
          steveJobs.Friends.Add(billGates);
          steveJobs.Friends.Add(robinHood);
          billGates.Friends.Add(billGates);
          robinHood.Friends.Add(steveJobs);
          session.Commit();
        }
      }
      catch (Exception ex)
      {
        Console.WriteLine(ex.ToString());
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:27,代码来源:Sample3.cs

示例7: SingleReaderSingleUpdater1

 public void SingleReaderSingleUpdater1()
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     Man man = new Man();
     man.Persist(session, man);
     session.Commit();
   }
   UInt64 id;
   using (SessionNoServer session = new SessionNoServer(systemDir, 5000))
   {
     session.BeginUpdate();
     Man man = new Man();
     man.Persist(session, man);
     id = man.Id;
     using (SessionNoServer session2 = new SessionNoServer(systemDir))
     {
       session2.BeginRead();
       Man man2 = (Man)session2.Open(id);
       Assert.Null(man2);
       session2.Commit();
     }
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:26,代码来源:ReadersWithUpdater.cs

示例8: CreateData

 static void CreateData()
 {
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     bool dirExist = Directory.Exists(session.SystemDirectory);
     if (dirExist)
       Directory.Delete(session.SystemDirectory, true); // remove systemDir from prior runs and all its databases.
     Directory.CreateDirectory(session.SystemDirectory);
     File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"));
     DataCache.MaximumMemoryUse = 10000000000; // 10 GB, set this to what fits your case
     SessionBase.DefaultCompressPages = PageInfo.compressionKind.LZ4;
     session.BeginUpdate();
     BTreeMap<Int64, VelocityDbList<Person>> btreeMap = new BTreeMap<Int64, VelocityDbList<Person>>(null, session);
     session.Persist(btreeMap);
     for (int i = 0; i < 100000; i++)
     {
       Person p = new Person();
       GeoHash geohash = GeoHash.WithBitPrecision(p.Lattitude, p.Longitude);
       VelocityDbList<Person> personList;
       if (btreeMap.TryGetValue(geohash.LongValue, out personList))
         personList.Add(p);
       else
       {
         personList = new VelocityDbList<Person>(1);
         //session.Persist(p);
         personList.Add(p);
         session.Persist(personList);
         btreeMap.Add(geohash.LongValue, personList);
       }
     }
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:33,代码来源:GeoHashSample.cs

示例9: CompareString

 public void CompareString(int compArraySize)
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     AllSupported obj = new AllSupported(1);
     CompareByField<AllSupported> compareByField = new CompareByField<AllSupported>("aString", session);
     BTreeSet<AllSupported> sortedSet = new BTreeSet<AllSupported>(compareByField, session, 1000, (ushort) compArraySize);
     for (int i = 0; i < 10000; i++)
     {
       obj = new AllSupported(1);
       obj.aString = RandomString(10);
       sortedSet.Add(obj);
     }
     obj = new AllSupported(1);
     obj.aString = null;
     sortedSet.Add(obj);
     int ct = 0;
     AllSupported prior = null;
     foreach (AllSupported currentObj in (IEnumerable<AllSupported>)sortedSet)
     {
       if (prior != null)
       {
         if (prior.aString != null)
           if (currentObj.aString == null)
             Assert.Fail("Null is < than a non NULL");
           else
             Assert.Less(prior.aString, currentObj.aString);
       }
       prior = currentObj;
       ct++;
     }
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:35,代码来源:CompareByFieldTest.cs

示例10: Main

    static readonly string systemDir = "QuickStart"; // appended to SessionBase.BaseDatabasePath

    static int Main(string[] args)
    {
      using (SessionNoServer session = new SessionNoServer(systemDir))
      {
        Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
        try
        {
          session.BeginUpdate();
          Company company = new Company();
          company.Name = "MyCompany";
          session.Persist(company);
          Employee employee1 = new Employee();
          employee1.Employer = company;
          employee1.FirstName = "John";
          employee1.LastName = "Walter";
          session.Persist(employee1);
          session.Commit();
        }
        catch (Exception ex)
        {
          Trace.WriteLine(ex.Message);
          session.Abort();
        }
      }
      Retrieve();
      return 0;
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:29,代码来源:QuickStart.cs

示例11: AddSomeBicycles

 public void AddSomeBicycles()
 {
   try
   {
     using (SessionNoServer session = new SessionNoServer(s_systemDir))
     {
       session.BeginUpdate();
       for (int i = 0; i < 1000000; i++)
       {
         Bicycle bicycle = new Bicycle();
         bicycle.Color = "red";
         session.Persist(bicycle);
       }
       for (int i = 0; i < 10; i++)
       {
         Bicycle bicycle = new Bicycle();
         bicycle.Color = "blue";
         session.Persist(bicycle);
       }
       for (int i = 0; i < 10; i++)
       {
         Bicycle bicycle = new Bicycle();
         bicycle.Color = "yellow";
         session.Persist(bicycle);
       }
       session.Commit();
     }      
   }
   catch (Exception ex)
   {
     Console.WriteLine(ex.ToString());
   }
 }    
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:33,代码来源:OneDbPerClass.cs

示例12: CreateData

 static void CreateData()
 {
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     bool dirExist = Directory.Exists(session.SystemDirectory);
     if (dirExist)
     {
       return;
       Directory.Delete(session.SystemDirectory, true); // remove systemDir from prior runs and all its databases.
     }
     Directory.CreateDirectory(session.SystemDirectory);
     File.Copy(s_licenseDbFile, Path.Combine(session.SystemDirectory, "4.odb"));
     SessionBase.DefaultCompressPages = PageInfo.compressionKind.LZ4;
     session.BeginUpdate();
     CompareGeoObj comparer = new CompareGeoObj();
     var btreeSet = new BTreeSet<GeoObj>(comparer, session, 1000);
     for (int i = 0; i < s_numberOfSamples; i++)
     {
       var g = new GeoObj();
       btreeSet.Add(g);
     }
     session.Persist(btreeSet);
     session.Commit();
     Console.Out.WriteLine([email protected]"Done creating {s_numberOfSamples} GeoHashSample GeoObj ");
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:26,代码来源:GeoHashSample.cs

示例13: hashCodeComparerStringTest

 public void hashCodeComparerStringTest()
 {
   Oid id;
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     Placement place = new Placement(223, 1, 1, UInt16.MaxValue, UInt16.MaxValue);
     session.Compact();
     session.BeginUpdate();
     HashCodeComparer<string> hashCodeComparer = new HashCodeComparer<string>();
     BTreeSet<string> bTree = new BTreeSet<string>(hashCodeComparer, session);
     bTree.Persist(place, session);
     id = bTree.Oid;
     for (int i = 0; i < 100000; i++)
     {
       bTree.Add(i.ToString());
     }
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginRead();
     BTreeSet<string> bTree= (BTreeSet<string>)session.Open(id);
     int count = 0;
     foreach (string str in bTree)
     {
       count++;
     }
     Assert.True(100000 == count);
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:31,代码来源:BTreeTest.cs

示例14: Verify

 public void Verify(string dir)
 {
   using (SessionNoServer session = new SessionNoServer(dir))
   {
     session.BeginRead();
     session.Verify();
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:9,代码来源:SchemaTests.cs

示例15: VelocityDB

 static VelocityDB()
 {
     string systemDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "VelocityDB", "Databases", "MvCSample");
     if (Directory.Exists(systemDir))
       Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases.
     Session = new SessionNoServer(systemDir);
     Session.BeginUpdate();
     Session.Commit();
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:9,代码来源:VelocityDB.cs


注:本文中的SessionNoServer.Commit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。