I'm playing around with some Linq-SQL stuff, doing something like this:
var foo = from f in db.Foo where f.Bar > 5 select f;
which is all fine and dandy, and I know I can also do this:
var foo = from f in db.Foo where f.Bar > 5 select new { f.Bar, f.Baz };
What I want to know, is can I factor out the select part of that query, if I want to determine at runtime what parts of Foo to select? Such as:
var foo = from f in db.Foo where f.Bar > 5 select SomeMethodThatReturnsThePropertiesOfFooIReallyWant();
Edit to clarify: I'm looking for the syntax and return type of SomeMethod...().
If I wanted to do this some times:
select new { f.Bar, f.Baz };
but other times do this:
select new { f.Baz, f.Other };
Based on data in memory (without doing a giant case statement), how would i do that, if possible?