本文整理汇总了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()));
}
示例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);
}
示例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);
}