Do I have to run the query twice? I searched but not sure how relevant to 2.5 Adapter.
public MySpecialObject GetAllPeopleByPage(int itemsPerPage, int pageNumber, Dictionary<string, string> searchBucket)
{
EntityCollection<PersonEntity> people = new EntityCollection<PersonEntity>();
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.PersonEntity);
prefetchPath.Add(PersonEntity.PrefetchPathCompanyPerson).SubPath.Add(CompanyPersonEntity.PrefetchPathCompany);
IRelationPredicateBucket relPred = new RelationPredicateBucket();
foreach (string searchKey in searchBucket.Keys)
{
string searchValue = searchBucket[searchKey];
if (searchKey.Equals("Surname"))
{
relPred.PredicateExpression.Add(PersonFields.Surname % searchValue);
}
if (searchKey.Equals("FirstName"))
{
relPred.PredicateExpression.Add(PersonFields.FirstName % searchValue);
}
}
Adapter.FetchEntityCollection(people, relPred, -1, null, prefetchPath, pageNumber, itemsPerPage);
MySpecialObject currentPage = new MySpecialObject();
currentPage.People = people
currentPage.TotalAvailableRecords = ???? (ignore paging)??
return currentPage;
}
public class MySpecialObject
{
// YES PSEDUO I WOULD USE PROPERTIES
public List<PersonEntity> People;
public int TotalAvailableRecords;
}