public DynamicPropertyMetadata GetCollectionProperty(DynamicEntityMetadata dynamicEntityMetadata, DynamicPropertyMetadata dynamicPropertyMetadata)
        {
            var collectionProperties = dynamicEntityMetadata.DynamicPropertyMetadatas.Where(x => x.IsDynamicCollection() &&
                                                                                            x.TypeName() == dynamicEntityMetadata.TypeName()).Select(x => (DynamicCollectionEntityPropertyMetadata)x).ToList();

            if (collectionProperties.Count == 0)
            {
                return(null);
            }

            if (collectionProperties.Count == 1)
            {
                return(collectionProperties.First());
            }

            collectionProperties = collectionProperties.Where(x => x.InverseProperty != null && x.InverseProperty == dynamicPropertyMetadata.PropertyName()).ToList();

            if (collectionProperties.Count == 1)
            {
                return(collectionProperties.First());
            }

            if (collectionProperties.Count == 0)
            {
                return(null);
            }

            throw new Exception("Collection cannot be found in entity " + dynamicEntityMetadata.TypeName() + " for property " + dynamicPropertyMetadata.TypeName());
        }