I'm getting AmbiguousMatchException when I try to use the ServerMapping setting in a RecordField of a Store.I've found that this error is thrown in the method: Coolite.Ext.Web.StoreDataBound.GetFieldValue(), because is trying to get the value of a property that is defined in a proxied class (the class was proxied by NHibernate).In my case, the original class was: TimeKeeping.Common.Group, but NHibernate is proxying it as CProxyTypeTimeKeeping_Common_TablesGroupTables_NHibernate_ProxyINHibernateProxy1 because its first cache level. All the defined properties in the first class are redefined in the second class. That's why the Ambiguous Exception is thrown.If I try to use IsComplex instead of the ServerMapping property, I'm getting a different error, but i'm sure that is caused by something connected with this.Regards,Ariel
These are the steps you must follow:1) Open coolite sourcecode2) Add a reference to NHibernate dll3) Edit StoreDataBound.cs in Coolite.Ext.Web\Ext\Data4) Replace the function named GetFieldValue with this one
private object GetFieldValue(AutoGeneratedFieldProperties property, object obj, RecordField field) { if (field!= null && !string.IsNullOrEmpty(field.ServerMapping)) { string[] mapping = field.ServerMapping.Split('.'); if (mapping.Length > 1) { for (int i = 0; i < mapping.Length; i++) { PropertyInfo p = null; if (obj is NHibernate.Proxy.INHibernateProxy) p = obj.GetType().BaseType.GetProperty(mapping[i]); else p = obj.GetType().GetProperty(mapping[i]); obj = p.GetValue(obj, null); if (obj == null) { return null; } } return obj; } } return DataBinder.GetPropertyValue(obj, property.DataField); }
if (obj is NHibernate.Proxy.INHibernateProxy) p = obj.GetType().BaseType.GetProperty(mapping[i]); else p = obj.GetType().GetProperty(mapping[i]);
obj = p.GetValue(obj, null); if (obj == null) { return null; } }
return obj; } }
return DataBinder.GetPropertyValue(obj, property.DataField); }