none
Extension Methods for EF EntityObject RRS feed

  • Question

  • hi,

    i need clarification regarding the extension methods.

    i am using EF 4.0 and i need to write the extension methods to get the property name and the value of the Entity (say Customer, Interest, Collection)

    Is it possible to use extension method on EntityObject and access there derived class properties.

    Tuesday, August 30, 2011 6:28 AM

Answers

  • Hi,

    What have you tried that doesn't work ? I don't see why you couldn't cast to get those properties. Now I'm not sure why you need a extension method for this. Sometimes knowing what is your overall goal rather than how you currently plan to achieve this goal is more helpfull as someone could suggest perhaps another approach...

    Or do you mean you just want to know the type of the entity ? I'm not really sure if Customer, Interest, Collection are "properties" as you seems to tell or just the type of the EntityObject ?


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Tuesday, August 30, 2011 11:00 AM
  • Hello Chidambara,

    As far as I know, I think it's possible to use extension method on EntityObject to get the properties. Here is an example about using linq expressions and extension methods to get property name.

    http://stackoverflow.com/questions/5252176/linq-expressions-and-extension-methods-to-get-property-name

    I hope this can help you.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 5, 2011 7:15 AM
    Moderator

All replies

  • Hi,

    What have you tried that doesn't work ? I don't see why you couldn't cast to get those properties. Now I'm not sure why you need a extension method for this. Sometimes knowing what is your overall goal rather than how you currently plan to achieve this goal is more helpfull as someone could suggest perhaps another approach...

    Or do you mean you just want to know the type of the entity ? I'm not really sure if Customer, Interest, Collection are "properties" as you seems to tell or just the type of the EntityObject ?


    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".

    Tuesday, August 30, 2011 11:00 AM
  • Hello Chidambara,

    As far as I know, I think it's possible to use extension method on EntityObject to get the properties. Here is an example about using linq expressions and extension methods to get property name.

    http://stackoverflow.com/questions/5252176/linq-expressions-and-extension-methods-to-get-property-name

    I hope this can help you.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 5, 2011 7:15 AM
    Moderator