19 March 2008

an intersting thing happened to me on the way to databinding

i came across an interesting bug (yes, bug) in the .NET BoundField class. seems .NET doesn't care much for NHibernate. or duck typing. or both. given a data source of [proxy of EntityA, instance of EntityA], a bound field in a data view on my page no likey the binding.

basically, the symptom was that i got an annoying message that didn't tell me that the reflection the bound field used was expecting an instance of a different type than what it got, which surprised me, given that i thought i was binding to a list of two EntityA instances. well, if the first item is the proxy, the binding blows up; if the first is standard EntityA, the binding works. my guess is that the BoundField class caches a PropertyInfo class to use in retreiving the value of each successive item, and that PropertyInfo is bound to a particular type.

turns out i solved this problem by implementing my own BoundField (that further supports OGNLish syntax) by not caching. at least this class isn't sealed.

performance first!

No comments:

Post a Comment