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


C# BusinessObjectCollection.Sort方法代码示例

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


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

示例1: Test_CollectionLoad_Load_CriteriaString_Untyped

		public void Test_CollectionLoad_Load_CriteriaString_Untyped()
        {
            //---------------Set up test pack-------------------
            SetupDefaultContactPersonBO();
            //            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 + "'";

            //---------------Execute Test ----------------------
            BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
            col.Load(criteria, "Surname");

            //---------------Test Result -----------------------
            Assert.AreEqual(2, col.Count);
            col.Sort("Surname", true, true);
            Assert.AreSame(cp2, col[0]);
            Assert.AreSame(cp1, col[1]);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:21,代码来源:TestBusinessObjectLoader_GetBusinessObjectCollection.cs

示例2: CreateCollectionWithTestPack

 private static BusinessObjectCollection<ContactPersonTestBO> CreateCollectionWithTestPack(string firstName, out ContactPersonTestBO cp1, out ContactPersonTestBO cp2, out ContactPersonTestBO cp3)
 {
     ContactPersonTestBO.LoadDefaultClassDef();
     cp1 = ContactPersonTestBO.CreateSavedContactPerson("zzaaaa", firstName);
     cp2 = ContactPersonTestBO.CreateSavedContactPerson("aaaa", firstName);
     cp3 = ContactPersonTestBO.CreateSavedContactPerson("ZZZZZ", "FirstName");
     BusinessObjectCollection<ContactPersonTestBO> col = new BusinessObjectCollection<ContactPersonTestBO>();
     col.Load("", "Surname");
     col.Sort("Surname", true, true);
     return col;
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:11,代码来源:TestBusinessObjectCollection.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

示例4: Test_Sort_WhenOrderCriteriaSetup_AndCollectionSorted_ShouldNotChangeOrder

 public void Test_Sort_WhenOrderCriteriaSetup_AndCollectionSorted_ShouldNotChangeOrder()
 {
     //---------------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 ----------------------
     col.Sort();
     //---------------Test Result -----------------------
     Assert.AreEqual(2, col.Count);
     Assert.AreSame(cp2, col[0], "Collection should b sorted by the Surname Property as per the origional collection.Load");
     Assert.AreSame(cp1, col[1]);
 }
开发者ID:kevinbosman,项目名称:habanero,代码行数:24,代码来源:TestBusinessObjectCollection.cs

示例5: Test_Sort_WithoutOrderCriteria_ShouldDoNothing

        public void Test_Sort_WithoutOrderCriteria_ShouldDoNothing()
        {

            //---------------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, "");
            col.Sort("Surname", true, false);
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, col.Count);
            Assert.AreSame(cp1, col[0], "Collection should be in Surname Desc Order");
            Assert.AreSame(cp2, col[1], "Collection should be in Surname Desc Order");
            //---------------Execute Test ----------------------
            col.Sort();
            //---------------Test Result -----------------------
            Assert.AreEqual(2, col.Count);
            Assert.AreSame(cp1, col[0], "Collection Should not change the order since no default Sort criteria where set up");
            Assert.AreSame(cp2, col[1]);
        }
开发者ID:kevinbosman,项目名称:habanero,代码行数:25,代码来源:TestBusinessObjectCollection.cs

示例6: Test_Sort_WithExpression_AndReflectiveProperty_ShouldSortCollection

        public void Test_Sort_WithExpression_AndReflectiveProperty_ShouldSortCollection()
        {
            //---------------Set up test pack-------------------
            ContactPersonTestBO.LoadDefaultClassDef();
            //            DateTime now = DateTime.Now;
            const string firstName = "abab";
            var cp1 = ContactPersonTestBO.CreateSavedContactPerson("zzzz", firstName);
            cp1.ReflectiveProp = "ccc";
            var cp2 = ContactPersonTestBO.CreateSavedContactPerson("aaaa", firstName);
            cp2.ReflectiveProp = "bbb";
            //            Criteria criteria = new Criteria("DateOfBirth", Criteria.ComparisonOp.Equals, now);
            const string criteria = "FirstName = '" + firstName + "'";
            var col = new BusinessObjectCollection<ContactPersonTestBO>();
            col.Load(criteria, "Surname DESC");
            //---------------Assert Precondition----------------
            Assert.AreEqual(2, col.Count);
            Assert.AreSame(cp1, col[0], "Collection should be in Surname DESC Order");
            Assert.AreSame(cp2, col[1], "Collection should be in Surname DESC Order");

            //---------------Execute Test ----------------------
            col.Sort(contact => contact.ReflectiveProp, false,  true);
            //---------------Test Result -----------------------
            Assert.AreEqual(2, col.Count);
            Assert.AreSame(cp2, col[0], "Collection should be sorted by the ReflectiveProp Property ASC");
            Assert.AreSame(cp1, col[1]);
        }
开发者ID:Chillisoft,项目名称:habanero,代码行数:26,代码来源:TestBusinessObjectCollection.cs


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