Filtering a TypedView in Memory

Posts   
 
    
Stompi2007
User
Posts: 2
Joined: 22-Feb-2008
# Posted on: 22-Feb-2008 14:26:53   

Hi guys,

Urgent question, How do i filter a TypedView which has already been created and filtered? What i want to do is create and fill a TypedView, then pass this TypedView to another function which will then further filter the view using another predicate expression to filter it(Without accessing the database again).

Can this be done, and how?

If anybody has the answer, then plz could you let me know ASAP!

Thanks in advance!

Stompi

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 22-Feb-2008 16:04:11   

A typedView is a dataTable, and there is no special ways in LLBLGen to filter a TypedView in memory.

Here are your options.

Option #1: You can use something like this to filter a dataTable:

Dim rows as DataRow() = myTable.Select( "name like '%Mary%' order by LastModifiedTime" )

ref: http://www.dotnetspider.com/kb/Article614.aspx

Option #2: Re-fetch from the database (filter on the database side).

Option #3: Use an entityCollection from the start, which gives you the advantage of using an EntityView to filter its content in the memory. Needless to say you can map an entity to a database view.

Stompi2007
User
Posts: 2
Joined: 22-Feb-2008
# Posted on: 22-Feb-2008 16:24:59   

Thanks, I used the first option as my solution. Seems to work for me, but just have another question, Can the DefaultView.RowFilter be used in any way to filter the TypedView?

Thanks Stompi

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 22-Feb-2008 17:38:31   

Yes this also can be used.

Example:

DataView myView = myDataTable.DefaultView;

myView.RowFilter = "Name LIKE '%John%' or Title LIKE '%Manager%' ";