/// <summary> /// 获取指定名称的属性元素对象。 /// </summary> /// <param name="name">指定的属性名称,支持以点(.)为分隔符的属性名路径。</param> /// <returns>返回找到的属性元素,如果没有找到指定路径的属性元素则返回空(null)。</returns> public MetadataEntityProperty GetProperty(string name) { if (string.IsNullOrWhiteSpace(name)) { return(null); } var parts = name.Split('.'); var entity = this; MetadataEntityProperty property = null; foreach (var part in parts) { while (entity != null) { property = entity.Properties[part]; if (property == null) { entity = entity.BaseEntity; } else { var complexProperty = property as MetadataEntityComplexProperty; if (complexProperty != null) { entity = complexProperty.Relationship.GetToEntity(); } break; } } if (property == null) { return(null); } } return(property); }
private MetadataEntityProperty[] GetEntityReferences(string memberName) { var association = this.Association; if (association == null) { return(null); } var entity = association.Members[memberName].Entity; var refNames = association.Members[memberName].Properties; var refs = new MetadataEntityProperty[refNames.Length]; for (int i = 0; i < refs.Length; i++) { refs[i] = entity.Properties[refNames[i]]; } return(refs); }