From 7a268b984ebedd543fc4f66ed9dca8a4fbeee545 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Cano Date: Sun, 26 Jun 2022 01:40:21 +0200 Subject: [PATCH] overloads in TranslatedInstanceLogic.cs --- .../Translation/TranslatedInstanceLogic.cs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Signum.Engine.Extensions/Translation/TranslatedInstanceLogic.cs b/Signum.Engine.Extensions/Translation/TranslatedInstanceLogic.cs index a145d2be78..bf9d09c65b 100644 --- a/Signum.Engine.Extensions/Translation/TranslatedInstanceLogic.cs +++ b/Signum.Engine.Extensions/Translation/TranslatedInstanceLogic.cs @@ -268,11 +268,22 @@ where ti.PropertyRoute.RootType.Is(typeof(T).ToTypeEntity()) && ti.PropertyRoute select ti).UnsafeDelete(); } - public static string? TranslatedField(this T entity, Expression> property) where T : Entity + public static string TranslatedField(this T entity, Expression> property) where T : Entity { string? fallbackString = TranslatedInstanceLogic.GetPropertyRouteAccesor(property)(entity); - return entity.ToLite().TranslatedField(property, fallbackString); + var pr = PropertyRoute.Construct(property); + + return entity.ToLite().TranslatedField(pr, fallbackString); + } + + public static string? TranslatedFieldNullable(this T entity, Expression> property) where T : Entity + { + string? fallbackString = TranslatedInstanceLogic.GetPropertyRouteAccesor(property)(entity); + + var pr = PropertyRoute.Construct(property); + + return entity.ToLite().TranslatedField(pr, fallbackString); } public static IEnumerable> TranslatedMList(this E entity, Expression>> mlistProperty) where E : Entity @@ -289,7 +300,16 @@ public static IEnumerable> TranslatedMList(this E e } } - public static string? TranslatedElement(this TranslatableElement element, Expression> property) + public static string TranslatedElement(this TranslatableElement element, Expression> property) + { + string fallback = GetPropertyRouteAccesor(property)(element.Value); + + PropertyRoute route = element.ElementRoute.Continue(property); + + return TranslatedField(element.Lite, route, element.RowId, fallback); + } + + public static string? TranslatedElementNullable(this TranslatableElement element, Expression> property) { string? fallback = GetPropertyRouteAccesor(property)(element.Value);