Filter record

Posts   
 
    
weezer
User
Posts: 42
Joined: 24-Apr-2012
# Posted on: 10-Apr-2013 17:51:35   

I have the following code which use to filter the record based on the search criteria. What i wondering, is that possible i used the GetProjectData() to filter record for GetPersonData. Please advise, thank you

private EntityCollection<PersonResponsibleEntity> GetPersonData()
    {
        EntityCollection<PersonResponsibleEntity> collection = new EntityCollection<PersonResponsibleEntity>();
        DataAccessAdapter aAdaptor = clsDatabaseMethods.GetNewAdapter();
        IPrefetchPath2 path = new PrefetchPath2(EntityType.PersonResponsibleEntity);
        RelationPredicateBucket bucketbucket = new RelationPredicateBucket();
        aAdaptor.FetchEntityCollection(collection, bucketbucket);
        return collection;
    }
private EntityCollection<VwProjectCollectionEntity> GetProjectData()
    {

        EntityCollection<VwProjectCollectionEntity> collection = new EntityCollection<VwProjectCollectionEntity>();
        DataAccessAdapter aAdaptor = clsDatabaseMethods.GetNewAdapter();
        IPrefetchPath2 path = new PrefetchPath2(EntityType.VwProjectCollectionEntity);
        RelationPredicateBucket bucketbucket = new RelationPredicateBucket();
        //The following will check if the Show Completed only checkbox is checked or not
        if (chkShowCompleted.Checked)
        {
            bucketbucket.PredicateExpression.Add(VwProjectCollectionFields.DateCompleted != System.DBNull.Value);
        }
        else
        {
            bucketbucket.PredicateExpression.Add(VwProjectCollectionFields.DateCompleted == System.DBNull.Value);
        }


        //Add in predicate from search criteria
        if (bucket != null)
        {
            Int32 count = 0;
            while (count < bucket.Count)
            {
                bucketbucket.PredicateExpression.Add(bucket[count]);
                count += 1;
            }
        }
        SortExpression sort = new SortExpression();
        //Sorting by LastName
        ISortExpression aSortExpression = new SortExpression(VwProjectCollectionFields.LastName | SortOperator.Ascending);
        //Using the StartDateOrder to make sure CommunicateionStartDate order ASC and put the null date in buttom
        aSortExpression.Add(VwProjectCollectionFields.StartDateOrder | SortOperator.Ascending);
        aSortExpression.Add(VwProjectCollectionFields.CommunicationStartDate | SortOperator.Ascending);
        aAdaptor.FetchEntityCollection(collection, bucketbucket, 0, aSortExpression, path);
        return collection;
    }
Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 10-Apr-2013 19:09:51   

Not sure I understand your question. Besides what's the relation between Person and Project?

weezer
User
Posts: 42
Joined: 24-Apr-2012
# Posted on: 11-Apr-2013 03:13:16   

Basically i have retrieved the set of record using GetProjectData which also include the person. So the GetPersonData is only get all available from the personresponsible table

What my question is Can i filter the GetProjectData record and use to get GetPersonData

for example of record getting by GetProjectData

No Item Person 1. Adidas Jack 2. Nike Dilon 3. Puma Pete 4. Converse Manu

Then GetPersonData simply filter the GetProjectData for example only retrieve the person = Dilon

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Apr-2013 08:41:09   

So, you get some PersonData:

No Item Person 1. Adidas Jack 2. Nike Dilon 3. Puma Pete 4. Converse Manu

Then you need to get some ProjectData and use that persons to filter the project data. Then you should answer Walaa's question: What is the relation between Person and Project. Becase if Project->Person is m:1 then you just add something like:

public ... GetProjectData(..., List<int> personIds)
{
     ...
     bucket.Add(ProjectFields.PersonId == personIds);
     ...
}

... but if there is another kind of relation, then you should do it differently. I hope it was clear enough. If not, please elaborate more on a more basic scenario so we can understand what you really want.

David Elizondo | LLBLGen Support Team