How to Filter Entity using linq

Posts   
 
    
weezer
User
Posts: 42
Joined: 24-Apr-2012
# Posted on: 29-Mar-2013 17:26:30   

Hi Guys,

I just wondering if i can re filter the collection based on the following code. so i would like to do something like this in linq if possible:

EntityCollection<VwProjectCollectionEntity> collection= GetProjectData(); var workplan = (from collection where....

in sql query: select description from collection where title='test';

Please advise if that is possible. if it is possible

public void Generate() { ArrayList pgnodes = new ArrayList();
EntityCollection<VwProjectCollectionEntity> collection = GetProjectData();

}

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;
}
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Mar-2013 04:05:32   

Sure. It looks possible. What do you have written in Linq2LLBL so far? What exactly is the problem?

David Elizondo | LLBLGen Support Team