You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
internal static Dictionary<String, Object> ConvertInstanceToMap<E>( E instance )
{
if( instance == null )
throw new ArgumentException( ExceptionMessage.NULL_INSTANCE );
Dictionary<String, Object> entity = new Dictionary<String, Object>();
Type fieldsType = typeof( E );
FieldInfo[] fields = fieldsType.GetFields( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
foreach( FieldInfo field in fields )
entity[ field.Name ] = field.GetValue( instance );
return entity;
}
internal static String GetObjectIdFromInstance<E>( E instance )
{
if( instance == null )
throw new ArgumentException( ExceptionMessage.NULL_INSTANCE );
Type fieldsType = typeof( E );
FieldInfo[] fields = fieldsType.GetFields( BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance );
foreach( FieldInfo field in fields )
if( field.Name == "objectId" || field.Name == "ObjectId" )
return (String) field.GetValue( instance );
throw new ArgumentException( ExceptionMessage.NULL_OBJECT_ID_IN_INSTANCE );
}
These two methods read the field names from a Business Object rather than the property names. Because of that, transactions fail as it is looking for "objectId" etc when the field name is "_objectId" but the property name is "objectId"
Private fields tend to be internal to the class. Is it really the intention that it work this way?
I fixed it in my own project by forking the source and replacing FieldInfo with PropertyInfo for these two methods but I would rather stick with official releases.
The text was updated successfully, but these errors were encountered:
https://github.com/Backendless/.NET-SDK/blob/49d8bb46e7add11aac5ce24edd0c3ef8b9d6aaf2/Backendless/Transaction/TransactionHelper.cs
These two methods read the field names from a Business Object rather than the property names. Because of that, transactions fail as it is looking for "objectId" etc when the field name is "_objectId" but the property name is "objectId"
Private fields tend to be internal to the class. Is it really the intention that it work this way?
I fixed it in my own project by forking the source and replacing FieldInfo with PropertyInfo for these two methods but I would rather stick with official releases.
The text was updated successfully, but these errors were encountered: