Click here to Skip to main content
15,884,388 members
Home / Discussions / C#
   

C#

 
GeneralRe: Unexpected naming of client for a WCF service Pin
Tridip Bhattacharjee26-Oct-12 9:59
professionalTridip Bhattacharjee26-Oct-12 9:59 
AnswerRe: Unexpected naming of client for a WCF service Pin
Russell Bill26-Oct-12 11:47
Russell Bill26-Oct-12 11:47 
QuestionReading from XML file Pin
gibsray26-Oct-12 5:32
gibsray26-Oct-12 5:32 
AnswerRe: Reading from XML file Pin
Ravi Bhavnani26-Oct-12 5:47
professionalRavi Bhavnani26-Oct-12 5:47 
AnswerRe: Reading from XML file Pin
fjdiewornncalwe26-Oct-12 6:09
professionalfjdiewornncalwe26-Oct-12 6:09 
AnswerRe: Reading from XML file Pin
Clifford Nelson26-Oct-12 8:56
Clifford Nelson26-Oct-12 8:56 
AnswerRe: Reading from XML file Pin
gopal pradhan8-Nov-12 23:30
gopal pradhan8-Nov-12 23:30 
QuestionReflection and Linq Extension Methods Pin
Gustavo Ushijima26-Oct-12 3:53
Gustavo Ushijima26-Oct-12 3:53 
I have this code:
XML
public static IQueryable<T> OrderBy<T>(
               this IQueryable<T> source, string propertyName, string order)
        {
            var type = typeof(T);
            var asc = order == "asc" ? true:false;
            string methodName = asc ? "OrderBy" : "OrderByDescending";

            var parameter = Expression.Parameter(type, "p");
            var property = type.GetProperty(propertyName);

            var propertyAccess = Expression.MakeMemberAccess(parameter, property);
            var orderByExp = Expression.Lambda(propertyAccess, parameter);

            MethodCallExpression resultExp = Expression.Call(typeof(Queryable), methodName,
                              new Type[] { type, property.PropertyType },
                              source.Expression, Expression.Quote(orderByExp));
            return source.Provider.CreateQuery<T>(resultExp);
        }



And i would like to extend it to allow child properties, like "Address.Street"
if i pass just a simple property it works nice... but i want to make it better and accept child object property to make order by.


Anyone knows how to modify it?
I tryed but no success... i don't know how to make it to find the child object property and create the MemberAccess with it Dead | X|

Thanks!!
AnswerRe: Reflection and Linq Extension Methods Pin
onelopez26-Oct-12 4:19
onelopez26-Oct-12 4:19 
QuestionPrinting Automatically When A Particular Event Occurs Pin
Matt U.26-Oct-12 3:43
Matt U.26-Oct-12 3:43 
AnswerRe: Printing Automatically When A Particular Event Occurs Pin
Eddy Vluggen26-Oct-12 4:48
professionalEddy Vluggen26-Oct-12 4:48 
GeneralRe: Printing Automatically When A Particular Event Occurs Pin
Matt U.26-Oct-12 6:54
Matt U.26-Oct-12 6:54 
GeneralRe: Printing Automatically When A Particular Event Occurs Pin
Matt U.26-Oct-12 7:36
Matt U.26-Oct-12 7:36 
AnswerRe: Printing Automatically When A Particular Event Occurs Pin
Clifford Nelson26-Oct-12 9:02
Clifford Nelson26-Oct-12 9:02 
QuestionADO.NET 4 SqlConnection SqlDataAdapter Pin
devvvy25-Oct-12 23:34
devvvy25-Oct-12 23:34 
AnswerRe: ADO.NET 4 SqlConnection SqlDataAdapter Pin
Deflinek25-Oct-12 23:43
Deflinek25-Oct-12 23:43 
AnswerRe: ADO.NET 4 SqlConnection SqlDataAdapter Pin
Pete O'Hanlon25-Oct-12 23:55
mvePete O'Hanlon25-Oct-12 23:55 
GeneralRe: ADO.NET 4 SqlConnection SqlDataAdapter Pin
devvvy26-Oct-12 2:58
devvvy26-Oct-12 2:58 
GeneralRe: ADO.NET 4 SqlConnection SqlDataAdapter Pin
Eddy Vluggen26-Oct-12 3:33
professionalEddy Vluggen26-Oct-12 3:33 
GeneralRe: ADO.NET 4 SqlConnection SqlDataAdapter Pin
devvvy28-Oct-12 20:00
devvvy28-Oct-12 20:00 
AnswerRe: ADO.NET 4 SqlConnection SqlDataAdapter Pin
Simon_Whale26-Oct-12 0:31
Simon_Whale26-Oct-12 0:31 
Question[Help] Sending message automatically Pin
askersuku25-Oct-12 19:18
askersuku25-Oct-12 19:18 
AnswerRe: [Help] Sending message automatically Pin
Pete O'Hanlon25-Oct-12 23:51
mvePete O'Hanlon25-Oct-12 23:51 
QuestionTextBox not recognising Input Pin
chappie425-Oct-12 14:43
chappie425-Oct-12 14:43 
AnswerRe: TextBox not recognising Input Pin
Eddy Vluggen25-Oct-12 15:08
professionalEddy Vluggen25-Oct-12 15:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.