Skip to content

Commit

Permalink
Merge pull request #7470 from umbraco/v8/hotfix/7469-ambiguous-extens…
Browse files Browse the repository at this point in the history
…ion-method

#7469 - Fixed  Ambiguous…
  • Loading branch information
Claus authored Jan 17, 2020
2 parents 5ddc4b8 + baef282 commit df1e006
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public static class PublishedElementExtensions
/// <summary>
/// Gets the value of a property.
/// </summary>
public static TValue Value<TModel, TValue>(this TModel model, Expression<Func<TModel, TValue>> property, string culture = null, string segment = null, Fallback fallback = default, TValue defaultValue = default)
public static TValue ValueByExpression<TModel, TValue>(this TModel model, Expression<Func<TModel, TValue>> property, string culture = null, string segment = null, Fallback fallback = default, TValue defaultValue = default)
where TModel : IPublishedElement
{
var alias = GetAlias(model, property);
return model.Value<TValue>(alias, culture, segment, fallback, defaultValue);
}

// fixme that one should be public so ppl can use it
//This cannot be public due to ambiguous issue with external ModelsBuilder if we do not rename.
private static string GetAlias<TModel, TValue>(TModel model, Expression<Func<TModel, TValue>> property)
{
if (property.NodeType != ExpressionType.Lambda)
Expand All @@ -45,7 +45,7 @@ private static string GetAlias<TModel, TValue>(TModel model, Expression<Func<TMo
var attribute = member.GetCustomAttribute<ImplementPropertyTypeAttribute>();
if (attribute == null)
throw new InvalidOperationException("Property is not marked with ImplementPropertyType attribute.");

return attribute.Alias;
}
}
Expand Down

0 comments on commit df1e006

Please sign in to comment.