public static DirectedRelationship GetDirectedMappedRelationship(Entity entity, Reference reference) { Relationship relationship = reference.MappedRelationship(); if (relationship == null) throw new NHibernateMappingException("Could not find mapped relationship for Reference: " + reference.Name); ITable mappedTable = EntityMapper.GetPrimaryTable(entity); return new DirectedRelationship(relationship, mappedTable); }