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


C# SessionNoServer.DeleteObject方法代码示例

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


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

示例1: Main


//.........这里部分代码省略.........
          session.Commit();
        }
        using (SessionNoServer session = new SessionNoServer(s_systemDir))
        {
          session.BeginRead();
          Console.WriteLine("Blue Cars");
          BTreeSet<Car> bTree = session.Index<Car>("color");
          foreach (Car c in (from aCar in bTree where aCar.Color == "Blue" select aCar))
            Console.WriteLine(c.ToStringDetails(session));
          Console.WriteLine("Cars in fuel efficiency order");
          foreach (Car c in session.Index<Car>("litresPer100Kilometers"))
            Console.WriteLine(c.ToStringDetails(session));
          Console.WriteLine("Vehicles ordered modelYear, brandName, modelName, color");
          foreach (Vehicle v in session.Index<Vehicle>())
            Console.WriteLine(v.ToStringDetails(session));
          session.Commit();
        }
        using (SessionNoServer session = new SessionNoServer(s_systemDir))
        {
          session.TraceIndexUsage = true;
          session.BeginUpdate();
          // these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
          Car c = (from aCar in session.Index<Car>("color") where aCar.Color == "Blue" select aCar).First();
          c.Color = "Green";
          session.Commit();
        }
        using (SessionNoServer session = new SessionNoServer(s_systemDir))
        {
          session.TraceIndexUsage = true;
          session.BeginUpdate();
          // these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
          Car c = (from aCar in session.Index<Car>("color") where aCar.Color == "Green" select aCar).First();
          UInt64 id = c.Id;
          session.DeleteObject(id);
          session.Abort();
          session.BeginUpdate();
          session.DeleteObject(id);
          session.Commit();
        }
        using (SessionNoServer session = new SessionNoServer(s_systemDir))
        {
          session.TraceIndexUsage = true;
          Stopwatch sw = new Stopwatch();
          sw.Start();
          session.BeginRead();
          // these LINQ statements will trigger a binary search lookup (not a linear search) of the matching Car objects in the BTreeSet
          Console.WriteLine("Blue Cars");
          foreach (Car c in (from aCar in session.Index<Car>("color") where aCar.Color == "Blue" select aCar))
            Console.WriteLine(c.ToStringDetails(session));
          session.Commit();
          sw.Stop();
          Console.WriteLine(sw.Elapsed);
        }
        using (SessionNoServer session = new SessionNoServer(s_systemDir))
        {
          Stopwatch sw = new Stopwatch();
          sw.Start();
          session.BeginUpdate();
          for (int i = 0; i < 10000; i++)
          { // add some junk to make search harder
            car = new Car(color, maxPassengers, fuelCapacity, litresPer100Kilometers, modelYear, brandName, modelName, i,
            odometer, registrationState, registrationPlate + i, insuranceCompany, insurancePolicy);
            session.Persist(car);
          }
          session.Commit();
          sw.Stop();
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:67,代码来源:Indexes.cs


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