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


C# BusinessObjectCollection.Find方法代码示例

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


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

示例1: Test_FindByGuid

 public void Test_FindByGuid()
 {
     BusinessObjectCollection<MyBO> col = new BusinessObjectCollection<MyBO>();
     MyBO bo1 = new MyBO();
     col.Add(bo1);
     col.Add(new MyBO());
     Assert.AreSame(bo1, col.Find(bo1.MyBoID.GetValueOrDefault()));
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:8,代码来源:TestBusinessObjectCollection.cs

示例2: TestRefreshCollectionRefreshesNonDirtyObjects

        public void TestRefreshCollectionRefreshesNonDirtyObjects()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorDB();
            ContactPersonTestBO.DeleteAllContactPeople();

            SetupDefaultContactPersonBO();
            var col = new BusinessObjectCollection<ContactPersonTestBO>();

            var cp1 = ContactPersonTestBO.CreateSavedContactPerson();
            FixtureEnvironment.ClearBusinessObjectManager();
            ContactPersonTestBO.CreateSavedContactPerson();
            ContactPersonTestBO.CreateSavedContactPerson();
            col.LoadAll();
            var newSurname = Guid.NewGuid().ToString();
            cp1.Surname = newSurname;
            cp1.Save();
            var secondInstanceOfCP1 = col.Find(cp1.ContactPersonID);

            //--------------------Assert Preconditions----------
            Assert.IsFalse(col.Contains(cp1));
            Assert.AreEqual(3, col.Count);
            Assert.AreEqual(newSurname, cp1.Surname);
            Assert.AreNotSame(secondInstanceOfCP1, cp1);
            Assert.AreNotEqual(newSurname, secondInstanceOfCP1.Surname);
            Assert.IsFalse(cp1.Status.IsDirty);
            //---------------Execute Test ----------------------
            BORegistry.DataAccessor.BusinessObjectLoader.Refresh(col);

            //---------------Test Result -----------------------
            Assert.AreEqual(3, col.Count);
            Assert.AreNotSame(secondInstanceOfCP1, cp1);
            Assert.AreEqual(newSurname, secondInstanceOfCP1.Surname);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:34,代码来源:TestBusinessObjectLoader_RefreshCollectionDB.cs

示例3: Test_Find_ShouldReturnObject

 public void Test_Find_ShouldReturnObject()
 {
     //---------------Set up test pack-------------------
     ContactPersonTestBO.LoadDefaultClassDef();
     //            DateTime now = DateTime.Now;
     const string firstName = "abab";
     ContactPersonTestBO cp1 = ContactPersonTestBO.CreateSavedContactPerson("zzzz", firstName);
     ContactPersonTestBO cp2 = ContactPersonTestBO.CreateSavedContactPerson("aaaa", firstName);
     //            Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now);
     const string criteria = "FirstName = '" + firstName + "'";
     BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
     col.Load(criteria, "Surname");
     col.Sort("Surname", true, true);
     //---------------Assert Precondition----------------
     Assert.AreEqual(2, col.Count);
     Assert.AreSame(cp2, col[0], "Collection should be in Surname Asc Order");
     Assert.AreSame(cp1, col[1], "Collection should be in Surname Asc Order");
     //---------------Execute Test ----------------------
     ContactPersonTestBO foundCp = col.Find(bo => bo.Surname == "zzzz");
     //---------------Test Result -----------------------
     Assert.IsNotNull(foundCp);
     Assert.AreSame(cp1, foundCp);
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:23,代码来源:TestBusinessObjectCollection.cs


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