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
I encountered a problem when trying to update an value contained in a complex type with UpdateAll(). The generated SQL statement is invalid, the "SET ..." portion is empty.
I tracked it down to GetPropertyName() in ExpressionHelper.cs. Here only the Member name is returned but not its fully qualified name if it is a complex type.
So I adjusted the function to return the fully qualified name of the member. This seems to work for me but since I am not using a lot of EFUtilities functions I am not 100% sure if my change has other (bad :-)) implications.
So here is my code for discussion:
` public static string GetPropertyName<TSource, TProperty>(this Expression<Func<TSource, TProperty>> propertyLambda)
{
Type type = typeof(TSource);
var temp = propertyLambda.Body;
while (temp is UnaryExpression)
{
temp = (temp as UnaryExpression).Operand;
}
return GetFullyQualifiedPropertyName(temp as MemberExpression);
}
private static string GetFullyQualifiedPropertyName(MemberExpression member)
{
MemberExpression parentMember = member.Expression as MemberExpression;
if (parentMember != null)
return GetFullyQualifiedPropertyName(parentMember) + "." + member.Member.Name;
return member.Member.Name;
}`
Bernd
The text was updated successfully, but these errors were encountered:
Hi,
I encountered a problem when trying to update an value contained in a complex type with UpdateAll(). The generated SQL statement is invalid, the "SET ..." portion is empty.
I tracked it down to GetPropertyName() in ExpressionHelper.cs. Here only the Member name is returned but not its fully qualified name if it is a complex type.
So I adjusted the function to return the fully qualified name of the member. This seems to work for me but since I am not using a lot of EFUtilities functions I am not 100% sure if my change has other (bad :-)) implications.
So here is my code for discussion:
` public static string GetPropertyName<TSource, TProperty>(this Expression<Func<TSource, TProperty>> propertyLambda)
{
Type type = typeof(TSource);
Bernd
The text was updated successfully, but these errors were encountered: