• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SessionNoServer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

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


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


示例3: MainWindow

 public MainWindow()
 {
   InitializeComponent();
   if (Directory.Exists(systemDir))
     Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases.
   try
   {
     session = new SessionBase[4];
     thread = new Thread[4];
     session[0] = new SessionNoServer(systemDir, int.Parse(session1LockTimeout.Text));
     session[1] = new SessionNoServer(systemDir, int.Parse(session2LockTimeout.Text));
     session[2] = new SessionNoServer(systemDir, int.Parse(session3LockTimeout.Text));
     session[3] = new SessionNoServer(systemDir, int.Parse(session4LockTimeout.Text));
     session[0].BeginUpdate();
     Placement place = new Placement(10);
     Number number = new Number();
     session[0].Persist(place, number);
     number = new Number(2);
     place = new Placement(11);
     session[0].Persist(place, number);
     number = new Number(3);
     place = new Placement(12);
     session[0].Persist(place, number);
     session[0].Commit();
   }
   catch (Exception ex)
   {
     session1messages.Content = ex.Message;
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:30,代码来源:DatabaseLocking.xaml.cs


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


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


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


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


示例8: bSyncDeletedDatabases

    public void bSyncDeletedDatabases()
    {
      using (SessionBase session = new SessionNoServer(s_sync1))
      {
        using (var trans = session.BeginUpdate())
        {
          for (uint i = 10; i < 14; i++)
          {
            var database = session.OpenDatabase(i);
            session.DeleteDatabase(database);
          }
          session.Commit();
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          updateSession.SyncWith(readFromSession);
        }
      }

      using (SessionBase readFromSession = new SessionNoServer(s_sync1))
      {
        readFromSession.BeginRead();
        using (SessionBase updateSession = new SessionNoServer(s_sync2))
        {
          using (var trans = updateSession.BeginRead())
          {
            Assert.AreEqual(updateSession.OpenAllDatabases().Count, readFromSession.OpenAllDatabases().Count - 1); // - 1 due to additional change tracking databases in original 
          }
        }
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:35,代码来源:SyncTest.cs


示例9: CompareInt16

 public void CompareInt16()
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginUpdate();
     AllSupported obj = new AllSupported(1);
     CompareByField<AllSupported> compareByField = new CompareByField<AllSupported>("int16", session);
     BTreeSet<AllSupported> sortedSet = new BTreeSet<AllSupported>(compareByField, session, 1000, sizeof(Int16), true);
     for (int i = 0; i < 100000; i++)
     {
       obj = new AllSupported(1);
       obj.int16 = (Int16) randGen.Next(Int16.MinValue, Int16.MaxValue);
       sortedSet.Add(obj);
     }
     int ct = 0;
     AllSupported prior = null;
     foreach (AllSupported currentObj in (IEnumerable<AllSupported>)sortedSet)
     {
       if (prior != null)
         Assert.Less(prior.int16, currentObj.int16);
       prior = currentObj;
       ct++;
     }
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:26,代码来源:CompareByFieldTest.cs


示例10: TwoUpdaters1

 public void TwoUpdaters1()
 {
   Assert.Throws<OptimisticLockingFailed>(() =>
   {
     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:VelocityDB,项目名称:VelocityDB,代码行数:28,代码来源:MultipleUpdaters.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: 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


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


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


示例16: Main

 static void Main(string[] args)
 {
   CreateData();
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     session.BeginRead();
     int ct = GeoHashQuery.SearchGeoHashIndex(session, 32.715736, -117.161087, 10000).Count;
     Console.WriteLine([email protected]"GeoObj located in San Diego by 10000 meter radius: {ct}");
     ct = GeoHashQuery.SearchGeoHashIndex(session, 32.715736, -117.161087, 100000).Count;
     Console.WriteLine([email protected]"GeoObj located in San Diego by 100000 meter radius: {ct}");
     ct = GeoHashQuery.SearchGeoHashIndex(session, 40.730610, -73.935242, 10000).Count;
     Console.WriteLine([email protected]"GeoObj located in New York City by 10000 meter radius: {ct}");
     ct = GeoHashQuery.SearchGeoHashIndex(session, 40.730610, -73.935242, 100000).Count;
     Console.WriteLine([email protected]"GeoObj located in New York City by 100000 meter radius: {ct}");
     // Sweden bounding box
     ct = GeoHashQuery.SearchGeoHashIndex(session, 55.34, 10.96, 69.06, 24.17).Count;
     Console.WriteLine([email protected]"GeoObj located in Sweden: {ct}");
     // Alaska bounding box
     ct = GeoHashQuery.SearchGeoHashIndex(session, 51.21, -169.01, 71.39, -129.99).Count;
     Console.WriteLine([email protected]"GeoObj located in Alaska: {ct}");
     // California bounding box
     ct = GeoHashQuery.SearchGeoHashIndex(session, 32.53, -124.42, 42.01, -114.13).Count;
     Console.WriteLine([email protected]"GeoObj located in California: {ct}");
     // USA bounding box
     //GeoHashQuery.SearchGeoHashIndex(session, 18.9, -67.0, 71.4, 172.4);
     //Console.WriteLine([email protected]"Persons located in USA: {ct}");
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:28,代码来源:GeoHashSample.cs


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


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


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


示例20: Verify

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SessionProperties类代码示例发布时间:2022-05-24
下一篇:
C# SessionInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap