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


C# SessionNoServer.Persist方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: Create1Root

 public void Create1Root()
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     IssueTracker issueTracker = new IssueTracker(10, session);
     User user = new User(null, "[email protected]", "Mats", "Persson", "matspca");
     session.Persist(user);
     PermissionScheme permissions = new PermissionScheme(user);
     issueTracker.Permissions = permissions;
     session.Persist(issueTracker);
     session.Commit();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:14,代码来源:TrackerTests.cs

示例6: Main

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

    static int Main(string[] args)
    {
      SessionNoServer session = new SessionNoServer(systemDir);
      Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
      session.BeginUpdate();
      Person person = new Person("Robin", "Hood", 30);
      session.Persist(person);
      person = new Person("Bill", "Gates", 56);
      session.Persist(person);
      person = new Person("Steve", "Jobs", 56);
      session.Persist(person);
      session.Commit();
      return 0;
    }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:16,代码来源:Sample1.cs

示例7: 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

示例8: 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

示例9: GermanString

 public void GermanString()
 {
   UInt64 id = 0;
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     using (var trans = new TransactionScope())
     {
       session.BeginUpdate();
       VelocityDbSchema.Person person = new VelocityDbSchema.Person();
       person.LastName = "Med vänliga hälsningar";
       id = session.Persist(person);
       trans.Complete();
     }
   }
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     using (var trans = new TransactionScope())
     {
       session.BeginUpdate();
       VelocityDbSchema.Person person = session.Open<VelocityDbSchema.Person>(id);
       person.LastName = "Mit freundlichen Grüßen";
       trans.Complete();
     }
   }
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     using (var trans = new TransactionScope())
     {
       session.BeginUpdate();
       VelocityDbSchema.Person person = session.Open<VelocityDbSchema.Person>(id);
       person.LastName = "Med vänliga hälsningar";
       trans.Complete();
     }
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:35,代码来源:SystemTransaction.cs

示例10: 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

示例11: 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

示例12: Main

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

    static int Main(string[] args)
    {
      SessionNoServer session = new SessionNoServer(systemDir);
      Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
      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();
      Retrieve();
      return 0;
    }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:20,代码来源:QuickStart.cs

示例13: Main

 static void Main(string[] args)
 {
   SessionNoServer session = new SessionNoServer(systemDir);
   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); // the other persons will be persisted implicetly by reachability from "Steve Jobs" person object
   session.Commit();
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:11,代码来源:Program.cs

示例14: DoFileFolderTest

 public void DoFileFolderTest()
 {
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     session.NotifyBeforeCommit = NotifyBeforeCommit;
     session.BeginUpdate();
     DirectoryInfo dirInfo = new DirectoryInfo(s_sampleFolder);
     Folder folder = new Folder(dirInfo.Name, null, session);
     CreateDirectoriesAndFiles(dirInfo, folder, session);
     session.Persist(folder);
     session.Commit();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:13,代码来源:FileFolderTest.cs

示例15: HashSetAddNonPersisted

 public void HashSetAddNonPersisted()
 {
   UInt64 id;
   Person person = null;
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     session.BeginUpdate();
     var hashSet = new HashSet<Person>();
     for (int i = 0; i < 100; i++)
     {
       var p = new Person();
       session.Persist(p);
       hashSet.Add(p);
       if (i == 47)
       {
         person = p;
         Assert.IsFalse(hashSet.Add(person));
       }
     }
     id = session.Persist(hashSet);
     Assert.IsTrue(hashSet.Contains(person));
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     session.BeginRead();
     var hashSet = session.Open<HashSet<Person>>(id);
     Assert.AreEqual(100, hashSet.Count);
     int ct = 0;
     foreach (Person p in hashSet)
       ct++;
     Assert.IsTrue(hashSet.Contains(person));
     Assert.IsFalse(hashSet.Add(person));
     Assert.AreEqual(100, ct);
     session.Commit();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:37,代码来源:HashSetTest.cs


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