Example #1
0
        internal static IEnumerable <EdmPropertyPath> PropertyPathToEdmPropertyPath(
            PropertyPath path,
            EntityType entityType)
        {
            List <EdmProperty> edmPropertyList = new List <EdmProperty>();
            StructuralType     structuralType  = (StructuralType)entityType;

            for (int i = 0; i < path.Count; ++i)
            {
                EdmProperty edmProperty = structuralType.Members.OfType <EdmProperty>().SingleOrDefault <EdmProperty>((Func <EdmProperty, bool>)(p => p.GetClrPropertyInfo().IsSameAs(path[i])));
                if (edmProperty == null)
                {
                    throw Error.EntityMappingConfiguration_CannotMapIgnoredProperty((object)entityType.Name, (object)path.ToString());
                }
                edmPropertyList.Add(edmProperty);
                if (edmProperty.IsComplexType)
                {
                    structuralType = (StructuralType)edmProperty.ComplexType;
                }
            }
            EdmProperty property = edmPropertyList.Last <EdmProperty>();

            if (property.IsUnderlyingPrimitiveType)
            {
                return (IEnumerable <EdmPropertyPath>) new EdmPropertyPath[1]
                       {
                           new EdmPropertyPath((IEnumerable <EdmProperty>)edmPropertyList)
                       }
            }
            ;
            if (property.IsComplexType)
            {
                edmPropertyList.Remove(property);

                return((IEnumerable <EdmPropertyPath>)property.ToPropertyPathList(edmPropertyList));
            }
            return((IEnumerable <EdmPropertyPath>) new EdmPropertyPath[1]
            {
                EdmPropertyPath.Empty
            });
        }
Example #2
0
 public static List <EdmPropertyPath> ToPropertyPathList(
     this EdmProperty property)
 {
     return(property.ToPropertyPathList(new List <EdmProperty>()));
 }