Filtering SelectAll() result

Aug 3, 2010 at 7:43 PM

Hi.

I need to bind some data that has a property IsActive, so I need to remove the items that are not active. I use object datasource to bind the data to the controls. So, is there a way to filter the result of SelectAll() method, for example to use it with FilterExpression in the Generic Object Data Source?

Thanks in advance,

Teodora.

Developer
Aug 24, 2010 at 10:15 AM

Stating the obvious here, but:

 

SelectAll().Where(i => i.IsActive)

will give you an IQueryable of your entities where the IsActive (presumably bool) property is true. 

I'm not sure why you would need to pre-filter the results ("FilterExpression in the Generic Object Data Source") because SelectAll isn't enumerated until you say so. Therefore, you can add all sorts to the query in advance of this. 

Oh, and sorry for taking so long to reply - I only noticed this now. :)

Aug 28, 2010 at 12:25 PM

Hi,

I want to use filter expression for some simple filtering in the user interface. For example, if I have a check box "Select Active Only", then it would be easy just to pass "IsActive == true" to the general object data source. This would be easier than writing another function in the partial class of the MyEntityStaticRepository.