Filtering (Collection Vs TypedList)

Posts   
 
    
un.real
User
Posts: 12
Joined: 27-May-2005
# Posted on: 21-Jul-2005 13:41:10   

hello Otis;

it's me again simple_smile


I have lots of datagrids in my project. I use both TypedLists and Collections to fill my datagrids. I hope you can help me to write a filtering code that I can use with both TypedLists and Collections.

Actually, I have a filtering code for TypedLists but I couldn't make it work for the Collections.



SomeTableTypedList someTableTypedList1 = new SomeTableTypedList();
someTableTypedList1.Fill();
someTableTypedList1.DefaultView.RowFilter = "SomeField LIKE '"+TextBoxSomeField.Text+"*' ";
DataGrid1.DataSource = someTableTypedList1;
DataGrid1.DataBind();


this works for TypedLists, but collections don't have a DefaultView property. is there a way to handle filtering of Collections, similar to typedLists?

Note: I don't want to use FieldLikePredicate b'cuz if it involves, my work would become much a disaster.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Jul-2005 10:41:39   

No, filtering of entitycollections isn't yet supported. So you have to filter them manually.

Frans Bouma | Lead developer LLBLGen Pro
un.real
User
Posts: 12
Joined: 27-May-2005
# Posted on: 25-Jul-2005 10:53:46   

well, is there a way to parse entityCollections to DataTable type or something?

can I use the DataSource property of the DataGrid to assing a DataTable object? (...and then re-assing it back to DataGrid's DataSource) if yes, how? e.g:


SomeTableCollection someTableCollection1 = new SomeTableCollection();
someTableCollection1.GetMulti(null);
DataGrid.DataSource = someTableCollection1;
DataTable dt = (DataTable)DataGrid.DataSource; //IT BLOWS HERE, on runtime, ["specified cast is not valid"]
dt.DefaultView.RowFilter = "ColumnName LIKE '%bla%'";
DataGrid.DataSource = dt;
DataGrid.DataBind();

I have been trying all the tricks come in mind confused

I have to use collections as if they were DataTables. (or something which has the RowFilter property)

un.real
User
Posts: 12
Joined: 27-May-2005
# Posted on: 25-Jul-2005 15:31:56   

hopeless? cry

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 25-Jul-2005 17:10:21   

You can either fetch the data into a datatable directly by using SomeTableCollection.GetMultiAsDataTable()

you can also filter your collection manually: create a new collection, walk the current collection and copy over the entities you want to show.

Frans Bouma | Lead developer LLBLGen Pro
un.real
User
Posts: 12
Joined: 27-May-2005
# Posted on: 26-Jul-2005 15:32:00   

Do you mean DAOClasses.GetMultiAsDataTable?.. wink

nevermind Otis, I am doing it with Predicates (Althoug it brings much work on me). If I was able to make it similar to DataTable, that would save me from a lot of work.

Thank you for your help.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 26-Jul-2005 18:15:47   

un.real wrote:

Do you mean DAOClasses.GetMultiAsDataTable?.. wink

No, the methods GetMultiAsDataTable() on the entitycollections simple_smile

nevermind Otis, I am doing it with Predicates (Althoug it brings much work on me). If I was able to make it similar to DataTable, that would save me from a lot of work. Thank you for your help.

With the GetMultiAsDataTable methods it should work. These are declared static / shared so perhaps you missed them because of that in intellisense dropdowns.

Frans Bouma | Lead developer LLBLGen Pro