> One of the great things about SQL is that it's exceedingly easy to
> create queries on the fly. I'm trying to accomplish the same using
[quoted text clipped - 24 lines]
> Replacing Func<Person, bool> with Expression<Func<Person, bool>>
> causes a compile error.
Try this code instead:
void PopulateOldPeople()
{
Populate(p => p.BirthDate < DateTime.Now.AddYears(-65));
}
void PopulateWomen()
{
Populate(p => p.Sex = Sex.Woman);
}
void Populate(Expression<Func<Person, bool>> filter)
{
var people = DB.Persons.Where(filter);
foreach(Person p in people)
{
// Add item to list box
}
}
Query expressions are nice, but they're not really appropriate in this
case. Just calling the extension method manually is simpler here.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Bram - 09 Jan 2008 20:06 GMT
Thanks for your swift reply! It works like a charm!
Kind regards
Bram
> > One of the great things about SQL is that it's exceedingly easy to
> > create queries on the fly. I'm trying to accomplish the same using
[quoted text clipped - 56 lines]
> Jon Skeet - <sk...@pobox.com>http://www.pobox.com/~skeet Blog:http://www.msmvps.com/jon.skeet
> World class .NET training in the UK:http://iterativetraining.co.uk