internal static Type UnwrapPrimaryKey(Type type, PropertyRoute[] routes) { if (type.UnNullify() == typeof(PrimaryKey)) { return routes.Select(r => PrimaryKey.Type(r.RootType)).Distinct().SingleEx().Nullify(); } return type; }
internal static Entities.Implementations? GetImplementations(PropertyRoute[] propertyRoutes, Type cleanType) { if (!cleanType.IsIIdentifiable() && !cleanType.IsLite()) return (Implementations?)null; var only = propertyRoutes.Only(); if (only != null && only.PropertyRouteType == PropertyRouteType.Root) return Signum.Entities.Implementations.By(cleanType); var aggregate = AggregateImplementations(propertyRoutes.Select(pr => pr.GetImplementations())); return aggregate; }
internal static Expression UnwrapPrimaryKey(Expression expression, PropertyRoute[] routes) { if (expression.Type.UnNullify() == typeof(PrimaryKey)) { var unwrappedType = routes.Select(r => PrimaryKey.Type(r.RootType)).Distinct().SingleEx(); return Expression.Convert(Expression.Field(expression.UnNullify(), "Object"), unwrappedType.Nullify()); } return expression; }