I'm currently facing an issue with using Reflection on custom types. I have a method with the following signature:
protected static bool ReplacePropertyValue<TTargetResource, TValue>(TEntity entity, TResourcePatch resourcePatch, Expression<Func<TResource, TTargetResource>> sourceResourcePropertyExpression, Expression<Func<TTargetResource, TValue>> sourcePropertyExpression, Expression<Func<TEntity, TValue>> targetPropertyExpression)
where TEntity
is the database-entity I want to update. where TTargetResource
is the resource of the patch-document I want the new value from. where TValue
is the type of the property I want the new value from to be set in the entity.
resourcePatch
contains all the patch-instructions I want to apply to the entity
. sourceResourcePropertyExpression
is the expression for the resource with the new/changed value. sourcePropertyExpression
is the expression to the resource's property with the new/changed value. targetPropertyExpression
is the expression pointing to the property which should have the new/changed value.
However I am facing an issue where the targetPropertyExpression
is not a MemberExpression
. Below is the call of the method
ReplacePropertyValue(theEntity, resourcePatch, team => team.ParentTeam, pt => pt.Id, team => team.TeamParentTeamId)
However, the last param is shown as {team => Convert(team.TeamParentTeamId)}
and I don't get the point why. TeamParentTeamId
is of type Guid
. When used with another property of type Guid?
it works as expected.
Can anyone tell me why the first one (Guid
) is a Convert(...)
-expression?
Aucun commentaire:
Enregistrer un commentaire