Posted this about a month ago. Have received no replies. Is it because nobody cares about this issue, or nobody reads this list, or did I post it inappropriately somehow? Still curious...
On Jul 18, 8:28 am, rsr <[email protected]> wrote: > Using 2.1.2.ga - > I found a case where enabling the query cache on a query where a > result transformer is used causes an error: > System.Reflection.TargetException : Object does not match target > type. > way down in .BasicPropertyAccessor.BasicGetter.Get > > You can demonstrate this easily by modifying the test > CachedQueriesHandlesEntitiesParametersCorrectly and adding > .SetResultTransformer(new DistinctRootEntityResultTransformer()) > to the query. > > The problem is that we're calling > ForeignKeys.GetEntityIdentifierIfNotUnsaved and passing it the row > values while still in tuple form - an object[] where object[0] is the > entity. > > My solution was to add the following to > ForeignKeys.GetEntityIdentifierIfNotUnsaved: > > // When query cache + result transform is used, the > "entity" given here is still in > // tuple form. In the cases I've seen, at least, the > entity is the first item of a > // one item object array. If that is the case, extract > it here. > var entityAsTuple = entity as object[]; > if (entityAsTuple != null && entityAsTuple.Length == > 1) > entity = entityAsTuple[0]; > > and with this, the modified > CachedQueriesHandlesEntitiesParametersCorrectly passes, along with all > other tests in the test project. > > My question is - is this correct/sufficient? > Is there a better fix, maybe that has already been made somewhere? > > Thanks -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
