tags:

views:

112

answers:

2

Hi,

How can i convert a IQueryable Expression Tree to a Expression<Func<T,bool>> Expression.

IQueryable<Book> Books;

var query = Books.Where(p => p.Author.AuthorId == 5);

Expression<Func<Book, bool>> expression = ?????
+1  A: 
Expression<Func<Book, bool>> expression = p => p.Author.AuthorId == 5;
leppie
+2  A: 

You use the IQueryable.Expression Property to access the IQueryable's Expression tree.

kervin
can u elaborate your answer please ? maybe with an exemple
Yoann. B
Hello Yoann, what would you like to do with the Expression tree? Or, what is the big picture?
kervin
actually i want to convert a IQueryable Chain such as Books.WithAuthorName("Mike").WithTitle("Something") to a single Expression
Yoann. B
The framework already does that for you.
kervin