EntityCollection to Filtered EntityCollection

Posts   
 
    
LLBLGen
User
Posts: 43
Joined: 10-Apr-2006
# Posted on: 13-Sep-2006 16:23:59   

I couldnt find the best way to do this, but how do i do


Select * into BookStatus_A from BookStatusMaster

where CompanyID='A'

this is how i am doing but i just thought there must be a better way..

... EntityCollection<BookStatusMasterEntity> GetCompany_ABookCollection(string CompanyID) {

EntityCollection<BookStatusMasterEntity> BookStatusCollection = getCachedCollection()... this collection is Cached ..this is not fetched from DB.

IPredicateExpression filter = new PredicateExpression(); filter.Add(BookStatusMasterFields.CompanyID== CompanyID);

EntityCollection<BookStatusMasterEntity> BookStatus_A= new EntityCollection<BookStatusMasterEntity> (new... List<int> xx= BookStatusCollection.FindMatches(filter)

for(int i=0;i<xx.count;i++) { BookStatus_A.AddNew(); BookStatus_A[ i ] = BookStatusCollection[xx[ i ]]; }

return BookStatus_A;

}

Walaa avatar
Walaa
Support Team
Posts: 14987
Joined: 21-Aug-2005
# Posted on: 13-Sep-2006 16:38:19   

The code is not clear to me, would you please explain what are you trying to do?

Thanks

LLBLGen
User
Posts: 43
Joined: 10-Apr-2006
# Posted on: 13-Sep-2006 17:21:25   

Thank you for your quick response...

I have Cached the BookStatusMaster in hard drive as entity collection with a key so that i dont make multiple trip to DB. The status is unique for each company, this table has the name of the status and the companyID + other columns... something like this

Status.................CompanyID ....

Active.................. A Inactive................ A New...................... A InUse.................... B Deactive.................B Just arrived............B

in my drop down i have to show status based on the user's company (A or B)

i alredy have the BookStatusMaster entity collection retrived from Caching, now i just need a better way to filter and return the collection based on what companyId gets passed.

something like

Select * into BookStatus_A from BookStatusMaster where CompanyID='A'

and return BookStatus_A (select * from BookStatus_A)


i have also modified the code above, for some reason it omit out few char...

Walaa avatar
Walaa
Support Team
Posts: 14987
Joined: 21-Aug-2005
# Posted on: 14-Sep-2006 07:19:41   

You should use an entityView to filter the entityCollection in memory. Please refer to the LLBLGen Pro manual "Using the generated code -> Adapter/SelfServicing -> Using the EntityView(2) class"