I have a case where I load 25,000 records from a database into a ReadOnlyListBase list, then about 10,000 times have to go to the list to get specific matching items (usually 2-3).
This is what I have in the collection:
public List<OwnerSummary> SelectForAccount(int accountID)This part of the code was running dog slow. I eventually tracked it down to the CanReadProperty call every time I accessed owner.AccountID. I was using the reflection stack-trace version in the OwnerSummary class. When I switched to CanReadProperty("AccountID", true) the execution time for the above code went from 3-4 seconds to the expected negligible time.
Thanks for the post. Guess the moral of the story is to use the explicit overload when performance matters and/or for frequently accessed fields. Great to have true bench-marking to substantiate this "guideline".
WOW !!!!
This was EXACTLY what I was looking for.
It just saved my hide.
I could not figure out why in the world my form was taking so long to load.
I have a Parent with 6 children - 3 core and 3 summary.
Each child has several hundred items in them and it was taking forever to load up.
Commenting out the CanReadProperty - it loads almost instantly.
Thanks again for this post -wouldn't have thought to look there.
Kurt
In CSLA 3.5 there are two things:
1. The CanReadProperty() overload (and similar methods) that infer the property name are marked obsolete, so you can't use them anymore (unless you like compiler warnings)
2. The new ReadProperty<T>() and LoadProperty<T>() methods bypass authorization checks and validation, loading the property value directly - and so you do avoid this overhead entirely.
Copyright (c) Marimer LLC