https://github.com/umbraco/Umbraco-CMS/issues/7469 - Fixed Ambiguous extension method issue by renaming our extension method from Value to GetValue
This commit is contained in:
@@ -17,13 +17,14 @@ namespace Umbraco.Web
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the value of a property.
|
/// Gets the value of a property.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static TValue GetValue<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
|
where TModel : IPublishedElement
|
||||||
{
|
{
|
||||||
var alias = GetAlias(model, property);
|
var alias = GetAlias(model, property);
|
||||||
return model.Value<TValue>(alias, culture, segment, fallback, defaultValue);
|
return model.Value<TValue>(alias, culture, segment, fallback, defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//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)
|
private static string GetAlias<TModel, TValue>(TModel model, Expression<Func<TModel, TValue>> property)
|
||||||
{
|
{
|
||||||
if (property.NodeType != ExpressionType.Lambda)
|
if (property.NodeType != ExpressionType.Lambda)
|
||||||
|
|||||||
Reference in New Issue
Block a user