View Single Post
  #1 (permalink)  
Old March 29th, 2009, 11:27 AM
realkewl realkewl is offline
Authorized User
Join Date: Mar 2009
Posts: 27
Thanks: 1
Thanked 0 Times in 0 Posts
Default Page 107 converting to


I'm trying to re-write your examples using I'm stuck on page 107 trying tp create the lambda function and trying to sort the generic list.

Here's my code so far of the public function SortByPropertyname:
Public Function SortByPropertyName(ByVal propertyName AsString, ByVal ascending AsBoolean) As List(Of T)
Dim param As ParameterExpression
Dim body As Expression
Dim sortExpression As Expression(Of T)
param = Expression.Parameter(GetType(T), "N")
body = Expression.Convert(Expression.Property(param, propertyName), GetType(Object))
sortExpression = Expression.Lambda(body, param)
If ascending's where I'm stuck
End IfEnd Function
There are several things that I'm not 100% sure about. 1) If I've created the lambda function correct...and 2) I have no clue on how to do the orderby.

Thanks for your help and I'm really enjoying reading this book, the concepts are what I thought they should be, but could not put my finger on it until reading this book.

I will keep searching and if I do find my answer I will post it.