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


C# SessionNoServer.AllObjects方法代码示例

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


在下文中一共展示了SessionNoServer.AllObjects方法的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: OneMillionFindSingleRecordInTheMiddle

 public void OneMillionFindSingleRecordInTheMiddle()
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.BeginRead();
     var result = (from ComputerFileData computerFileData in session.AllObjects<ComputerFileData>()
                   where computerFileData.FileID == 500000
                   select computerFileData).First();
     session.Commit();
   }
 }
开发者ID:MerlinBrasil,项目名称:VelocityDB,代码行数:11,代码来源:LinqTest.cs

示例3: UnpersistFileFoldersTest

 public void UnpersistFileFoldersTest()
 {
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     session.NotifyBeforeCommit = NotifyBeforeCommit;
     session.BeginUpdate();
     Assert.Less(10, session.AllObjects<Folder>().Count);
     Assert.Less(10, session.AllObjects<FileInDb>().Count);
     DirectoryInfo dirInfo = new DirectoryInfo(s_sampleFolder);
     Folder folder = (from f in session.AllObjects<Folder>(false) where f.Name == dirInfo.Name && f.ParentFolder == null select f).FirstOrDefault();
     folder.Unpersist(session);
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     session.BeginRead();
     Assert.AreEqual(0, session.AllObjects<Folder>().Count);
     Assert.AreEqual(0, session.AllObjects<FileInDb>().Count);
     session.Commit();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:21,代码来源:FileFolderTest.cs

示例4: Retrieve

    static void Retrieve()
    {
      using (SessionNoServer session = new SessionNoServer(systemDir))
      {
        session.BeginRead();
        // get all companies from database
        IEnumerable<Company> companies = session.AllObjects<Company>();

        // get all employees that FirstName contains "John"
        IEnumerable<Employee> employees = session.AllObjects<Employee>();
        var query = from Employee emp in employees
                    where emp.FirstName.Contains("John")
                    select emp;

        foreach (Employee emp in query)
        {
          //do something with employee
          emp.ToString();
        }

        // get all Employees that are over 30 years old and are from Berlin:
        var query2 = from Employee emp in employees
                     where emp.Age > 30 && emp.City == "Berlin"
                     select emp;

        foreach (Employee emp in query2)
        {
          //do something with employee
          emp.ToString();
        }
        // get all Employees that work at "MyCompany" company:
        var query3 = from Employee emp in employees
                     where emp.Employer.Name == "MyCompany"
                     select new { emp.FirstName, emp.LastName };
        session.Commit();
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:37,代码来源:QuickStart.cs

示例5: LoginButton_Click

 protected void LoginButton_Click(object sender, EventArgs e)
 {
   if (Password.Text.Length == 0)
   {
     ErrorMessage.Text = "Enter your password.";
     return;
   }
   try
   {
     using (SessionNoServer session = new SessionNoServer(s_dataPath, 2000, true, true))
     {
       session.BeginUpdate();
       Root velocityDbroot = session.AllObjects<Root>(false).FirstOrDefault();
       if (velocityDbroot == null)
       {
         ErrorMessage.Text = "The entered email address is not registered with this website";
         session.Abort();
         return;
       }
       CustomerContact lookup = new CustomerContact(Email.Text, null);
       if (!velocityDbroot.customersByEmail.TryGetKey(lookup, ref lookup))
       {
         ErrorMessage.Text = "The entered email address is not registered with this website";
         session.Abort();
         return;
       }
       if (lookup.password != Password.Text)
       {
         ErrorMessage.Text = "The entered password does not match the registered password";
         session.Abort();
         return;
       }
       session.Commit();
       Session["UserName"] = lookup.UserName;
       Session["Email"] = Email.Text;
       Session["FirstName"] = lookup.FirstName;
       Session["LastName"] = lookup.LastName;
       FormsAuthentication.RedirectFromLoginPage(Email.Text, false);
     }
   }
   catch (System.Exception ex)
   {
     ErrorMessage.Text = ex.ToString() + ex.Message;
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:45,代码来源:Login.aspx.cs

示例6: Button_Click

 private void Button_Click(object sender, RoutedEventArgs e)
 {
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     Console.WriteLine("Running with databases in directory: " + session.SystemDirectory);
     const UInt32 numberOfPersons = 10000;
     const ushort nodeMaxSize = 5000;
     const ushort comparisonByteArraySize = sizeof(UInt64); // enough room to hold entire idNumber of a Person
     const bool comparisonArrayIsCompleteKey = true;
     const bool addIdCompareIfEqual = false;
     Person person;
     session.BeginUpdate();
     session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.None;
     //mySession.SetTraceAllDbActivity();
     BTreeSet<string> stringSet = new BTreeSet<string>(null, session);
     BTreeSetOidShort<string> stringSetShort = new BTreeSetOidShort<string>(null, session);
     BTreeMap<string, string> stringMap = new BTreeMap<string, string>(null, session);
     BTreeMapOidShort<string, string> stringMapShort = new BTreeMapOidShort<string, string>(null, session);
     CompareByField<Person> compareByField = new CompareByField<Person>("idNumber", session, addIdCompareIfEqual);
     BTreeSet<Person> bTree = new BTreeSet<Person>(compareByField, session, nodeMaxSize, comparisonByteArraySize, comparisonArrayIsCompleteKey);
     session.Persist(bTree); // Persist the root of the BTree so that we have something persisted that can be flushed to disk if memory available becomes low
     for (int i = 0; i < numberOfPersons; i++)
     {
       person = new Person();
       // session.Persist(person);
       bTree.AddFast(person);
     }
     session.Commit();
   }
   using (SessionNoServer session = new SessionNoServer(systemDir))
   {
     session.UseExternalStorageApi = true;
     session.BeginRead();
     BTreeSet<Person> bTree = session.AllObjects<BTreeSet<Person>>().First();
     foreach (Person person in (IEnumerable<Person>)bTree)
     {
       if (person.IdNumber > 196988888791402)
       {
         Console.WriteLine(person);
         break;
       }
     }
     session.Commit();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:45,代码来源:MainPage.xaml.cs

示例7: Create3Versions

 public void Create3Versions(int numberOfVersions)
 {
   ProductVersion version = null;
   ProductVersion priorVersion = null;
   for (int i = 0; i < numberOfVersions; i++)
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
       session.BeginUpdate();
       IssueTracker issueTracker = session.AllObjects<IssueTracker>(false).FirstOrDefault();
       User user = issueTracker.UserSet.Keys[rand.Next(issueTracker.UserSet.Keys.Count - 1)];
       string v = "version" + i.ToString();
       string d = "vdescription" + i.ToString();
       version = new ProductVersion(user, v, d, null);
       session.Persist(version);
       issueTracker.VersionSet.Add(version);
       priorVersion = version;
       session.Commit();
     }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:19,代码来源:TrackerTests.cs

示例8: Main

 static void Main(string[] args)
 {
   try
   {
     using (SessionNoServer session = new SessionNoServer(s_systemDir))
     {
       DatabaseLocation localLocation = new DatabaseLocation(Dns.GetHostName(), Path.Combine(session.SystemDirectory, "desEncryptedLocation"), desEncryptedStartDatabaseNumber, UInt32.MaxValue,
         session, PageInfo.compressionKind.LZ4, PageInfo.encryptionKind.desEncrypted);
       session.BeginUpdate();
       session.NewLocation(localLocation);
       localLocation.DesKey = SessionBase.TextEncoding.GetBytes("5d9nndwy"); // Des keys are 8 bytes long
       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();
     }
     using (SessionNoServer session = new SessionNoServer(s_systemDir))
     { // Des keys are not persisted in DatabaseLocation (for safety). Instead they are stored as *.des files
       // in the users document directory of the user that created the DatabaseLocation. These files can be copied
       // to other user's document directory when acccess is desired for other users. 
       // Path to user document dir is given by C#: Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
       session.BeginRead();
       var allPersonsEnum = session.AllObjects<Person>();
       foreach (Person obj in allPersonsEnum)
       {
         Person person = obj as Person;
         if (person != null)
           Console.WriteLine(person.FirstName);
       }
       session.Commit();
     }
   }
   catch (Exception ex)
   {
     Console.WriteLine(ex.ToString());
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:43,代码来源:DesEncrypted.cs

示例9: Create2Users

 public void Create2Users(int numberOfUsers)
 {
   User user = null;
   User priorUser = null;
   for (int i = 0; i < numberOfUsers; i++)
     using (SessionNoServer session = new SessionNoServer(systemDir))
     {
       session.BeginUpdate();
       IssueTracker issueTracker = session.AllObjects<IssueTracker>(false).FirstOrDefault();
       string email = i.ToString() + "@gmail.com";
       string first = "first" + i.ToString();
       string last = "last" + i.ToString();
       string userName = "username" + i.ToString();
       user = new User(user, email, first, last, userName);
       session.Persist(user);
       issueTracker.UserSet.Add(user);
       priorUser = user;
       session.Commit();
     }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:20,代码来源:TrackerTests.cs

示例10: Main

    static readonly string s_systemDir = "UpdateClass"; // appended to SessionBase.BaseDatabasePath

    static int Main(string[] args)
    {
      try
      {
        UpdatedClass updatedClassObject;
        int ct1 = 0;
        using (SessionNoServer session = new SessionNoServer(s_systemDir))
        {
          session.BeginUpdate();
          session.UpdateClass(typeof(UpdatedClass)); // call this when you have updated the class since first storing instances of this type or since last call to UpdateClass
          UInt32 dbNum = session.DatabaseNumberOf(typeof(UpdatedClass));
          foreach (UpdatedClass obj in session.AllObjects<UpdatedClass>())
          {
            Console.Write(obj.ToString() + " has members: ");
            foreach (DataMember member in obj.GetDataMembers())
            {
              Console.Write(member.ToString() + " ");
            }
            Console.WriteLine();
            obj.UpdateTypeVersion(); // comment out if you DO NOT want to migrate this object to the latest version of the class
            ct1++;
          }
          int ct2 = 0;
          Database db = session.OpenDatabase(dbNum, true, false);
          if (db != null)
            foreach (UpdatedClass obj in db.AllObjects<UpdatedClass>())
              ct2++;
          Debug.Assert(ct1 == ct2);         
          updatedClassObject = new UpdatedClass();
          session.Persist(updatedClassObject);
          session.Commit();
        }
      }
      catch (Exception ex)
      {
        Console.WriteLine(ex.ToString());
        return 1;
      }
      return 0;
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:42,代码来源:UpdateClass.cs

示例11: ForgotPasswordLinkButton_Click

 protected void ForgotPasswordLinkButton_Click(object sender, EventArgs e)
 {
   try
   {
     using (SessionNoServer session = new SessionNoServer(s_dataPath, 2000, true, true))
     {
       session.BeginRead();
       Root root = session.AllObjects<Root>(false).FirstOrDefault();
       if (root == null)
       {
         ErrorMessage.Text = "The entered email address is not registered with this website";
         session.Abort();
         return;
       }
       CustomerContact lookup = new CustomerContact(Email.Text, null);
       if (!root.customersByEmail.TryGetKey(lookup, ref lookup))
       {
         ErrorMessage.Text = "The entered email address is not registered with this website";
         session.Abort();
         return;
       }
       session.Commit();
       MailMessage message = new MailMessage("[email protected]", Email.Text);
       message.Subject = "Your password to VelocityWeb";
       message.Body = "Password is: " + lookup.password;
       SmtpClient client = new SmtpClient("smtpout.secureserver.net", 80);
       System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential("[email protected]", "xxxx");
       client.Credentials = SMTPUserInfo;
       client.Send(message);
       ErrorMessage.Text = "Email with your password was send to: " + Email.Text;
     }
   }
   catch (System.Exception ex)
   {
     ErrorMessage.Text = ex.ToString();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:37,代码来源:Login.aspx.cs

示例12: dSyncDeletePages

    public void dSyncDeletePages()
    {
      using (SessionBase session = new SessionNoServer(s_sync1))
      {
        using (var trans = session.BeginUpdate())
        {
          foreach (FourPerPage fourPerPage in session.AllObjects<FourPerPage>())
            fourPerPage.Unpersist(session);
          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.AllObjects<FourPerPage>().Count, readFromSession.AllObjects<FourPerPage>().Count);
          }
        }
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:32,代码来源:SyncTest.cs

示例13: cSyncNewPages

    public void cSyncNewPages()
    {
      using (SessionBase session = new SessionNoServer(s_sync1))
      {
        using (var trans = session.BeginUpdate())
        {
          for (uint i = 0; i < 100; i++)
          {
            FourPerPage fourPerPage = new FourPerPage(i);
            session.Persist(fourPerPage);
          }
          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.AllObjects<FourPerPage>().Count, readFromSession.AllObjects<FourPerPage>().Count);
          }
        }
      }
    }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:35,代码来源:SyncTest.cs

示例14: lookupUser

 User lookupUser(IssueTracker issueTracker, SessionBase session)
 {
   string userEmail = this.User.Identity.Name;
   User user = new User(userEmail);
   string dataPath = HttpContext.Current.Server.MapPath("~/Database");
   if (!issueTracker.UserSet.TryGetValue(user, ref user))
   {
     CustomerContact existingCustomer = null;
     string firstName = null;
     string lastName = null;
     string userName = null;
     try
     {
       using (SessionNoServer session2 = new SessionNoServer(dataPath, 2000, true, true))
       {
         session2.BeginRead();
         Root velocityDbroot = session2.AllObjects<Root>(false).FirstOrDefault();
         CustomerContact lookup = new CustomerContact(userEmail, null);
         velocityDbroot.customersByEmail.TryGetKey(lookup, ref existingCustomer);
         session2.Commit();
         firstName = existingCustomer.FirstName;
         lastName = existingCustomer.LastName;
         userName = existingCustomer.UserName;
       }
     }
     catch (System.Exception ex)
     {
       this.errorLabel.Text = ex.ToString();
     }
     user = new User(null, userEmail, firstName, lastName, userName);
     session.Persist(user);
     issueTracker.UserSet.Add(user);
   }
   return user;
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:35,代码来源:Issues.aspx.cs

示例15: CreateEdges

 public void CreateEdges()
 {
   Create1Vertices(true);
   using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true))
   {
     session.BeginUpdate();
     Graph g = Graph.Open(session); // it takes a while to open graph fresh from databases
     VertexType userType = g.FindVertexType("User");
     VertexType locationType = g.FindVertexType("Location");
     EdgeType friendEdgeType = g.FindEdgeType("Friend");
     EdgeType userLocationEdgeType = g.FindEdgeType("UserLocation");
     int lineNumber = 0;
     long fiendsCt = 0;
     foreach (string line in File.ReadLines(inputData))
     {
       string[] fields = line.Split(' ');
       Vertex aUser = new Vertex(g, userType, ++lineNumber);
       int locationCt = 1;
       foreach (string s in fields)
       {
         if (s.Length > 0)
         {
           ++fiendsCt;
           Vertex aFriend = new Vertex(g, userType, int.Parse(s));
           Vertex aLocation = new Vertex(g, locationType, locationCt++);
           friendEdgeType.NewEdge(aUser, aFriend);
           userLocationEdgeType.NewEdge(aUser, aLocation);
         }
       }
       if (lineNumber >= 5000)
         break;
     }
     Console.WriteLine("Done importing " + lineNumber + " users with " + fiendsCt + " friends");
     session.Commit();
     session.BeginRead();
     foreach (var x in session.AllObjects<BTreeSet<Range<VertexId>>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeSet<EdgeType>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeSet<EdgeIdVertexId>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeMap<EdgeId, VelocityDbList<ElementId>>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeMap<string, PropertyType>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeMap<string, EdgeType>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeMap<string, VertexType>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     foreach (var x in session.AllObjects<BTreeMap<EdgeType, BTreeMap<VertexType, BTreeMap<VertexId, BTreeSet<EdgeIdVertexId>>>>>(false, true))
       Assert.True(x.ToDoBatchAddCount == 0);
     session.Commit();
     Validate();
   }
 }
开发者ID:VelocityDB,项目名称:VelocityDB,代码行数:59,代码来源:VelocityGraphTest.cs


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