none
how to get propertyValue perfomance is key factor RRS feed

  • Question

  • Hi,
        
                Now im using reflection to get the propertyvalue like

    Type.GetProperty(propertyName).GetValue()            if the number of items increases like more than 10 thousand loading the page is very slow is there any way to incease the perfomance or any alternate way to get the propertyvalue without using reflection?

    Thanks

    Monday, April 27, 2009 6:34 AM

Answers

  • Introduce an interface (one or more) that declares the properties you need, make your objects implement the interface(s) and get the values directly

    var idea = ((IGeneratorOfIdeas)foo).GetIdea();
    • Marked as answer by Zhi-Xin Ye Monday, May 4, 2009 12:35 PM
    Monday, April 27, 2009 1:48 PM

All replies

  • Either start using objects or dont load more then 10 thousand items :)
    Why would u use reflection like that?

    Monday, April 27, 2009 7:42 AM
  • If you are using reflection, you are only loading the page one time for all time so performance shouldn't be an issue.  Reflection and performance are mutually exclusive.
    Monday, April 27, 2009 8:39 AM
  • Reflection and performance are mutually exclusive.
    Might be a bit offtopic, but could u elaborate a bit more on that? I always had the impression reflection was slow and resource heavy.
    Monday, April 27, 2009 9:08 AM
  • hi,

             on the page Load the object contains 10000 item  with 140 property ,im adding ASP.net Table ctrl dynamically and for filling the tableCell i need the values for that  im traversing through the object and get the propertyVAlue by pasiing the Propertyname using reflection.

    so its taking quite long time for craeting the Table inturn loading is taking time.

    Thanks
    Monday, April 27, 2009 9:18 AM
  • Reflection and performance are mutually exclusive.
    Might be a bit offtopic, but could u elaborate a bit more on that? I always had the impression reflection was slow and resource heavy.

    I thought that was what I was saying.  Doesn't that phrase say the same thing that your response does?  You can't have reflection and performance at the same time.
    Monday, April 27, 2009 9:29 AM
  • Reflection and performance are mutually exclusive.
    Might be a bit offtopic, but could u elaborate a bit more on that? I always had the impression reflection was slow and resource heavy.

    I thought that was what I was saying.  Doesn't that phrase say the same thing that your response does?  You can't have reflection and performance at the same time.
    You are right, i was looking at it a bit differently :)
    Monday, April 27, 2009 9:33 AM
  • Introduce an interface (one or more) that declares the properties you need, make your objects implement the interface(s) and get the values directly

    var idea = ((IGeneratorOfIdeas)foo).GetIdea();
    • Marked as answer by Zhi-Xin Ye Monday, May 4, 2009 12:35 PM
    Monday, April 27, 2009 1:48 PM