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
It would be nice to be able to use mappings for shipping address city and Delivery address city like this:
mapper.AddMapping("shipping address city", x => x.ShippingAddress.City); // handle expression with nested property accessors. For sure it is possible to use refrection on nested objects
So now i get "something like cannot convert cell string to type string".
Something like this would help
publicstatic(PropertyInfopropertyInfo,stringfullPath)GetPropertyInfo<T>(Expression<Func<T,object>>propertySelector){if(propertySelectoris not LambdaExpressionlambdaExpression){thrownewArgumentException($"Unsupported property selector: {propertySelector}",nameof(propertySelector));}varpathBuilder=newStringBuilder();varbody=lambdaExpression.Body;while(bodyisMemberExpression or UnaryExpression{Operand:MemberExpression}){varmemberAccess=bodyasMemberExpression??(MemberExpression)((UnaryExpression)body).Operand;if(pathBuilder.Length>0){pathBuilder.Insert(0,".");}pathBuilder.Insert(0,memberAccess.Member.Name);body=memberAccess.Expression;}if(pathBuilder.Length>0){pathBuilder.Insert(0,typeof(T).Name+".");}varlambdaBody=lambdaExpression.Body.NodeType==ExpressionType.MemberAccess?(MemberExpression)lambdaExpression.Body:(MemberExpression)((UnaryExpression)lambdaExpression.Body).Operand;// for nullable value such as int?// body.Member will return the MemberInfo of the base class, so we have to get it from T...//return (PropertyInfo)body.Member;varpropertyInfo=lambdaBody.Expression.Type.GetProperty(lambdaBody.Member.Name);return(propertyInfo,pathBuilder.ToString());}
Having separate mapping for type is making impossible to map different properties of same type to excel, maybe there is a way but i seems like i have stuck with using custom mapping funcs.
Please advise,
Best regards
The text was updated successfully, but these errors were encountered:
Hi!
I'm facing an issue with nested object mapping from excel:
It would be nice to be able to use mappings for shipping address city and Delivery address city like this:
mapper.AddMapping("shipping address city", x => x.ShippingAddress.City); // handle expression with nested property accessors. For sure it is possible to use refrection on nested objects
So now i get "something like cannot convert cell string to type string".
Something like this would help
Having separate mapping for type is making impossible to map different properties of same type to excel, maybe there is a way but i seems like i have stuck with using custom mapping funcs.
Please advise,
Best regards
The text was updated successfully, but these errors were encountered: