public IRelationshipDef MapOneToMany()
{
var propertyType = this.PropertyWrapper.PropertyType;
if(!MustBeMapped()) return null;
var singleReverseRelPropInfos = this.PropertyWrapper.GetSingleReverseRelPropInfos();
if (singleReverseRelPropInfos.Count > 1)
{
throw new InvalidDefinitionException("The Relationship '" + this.PropertyWrapper.Name
+ "' could not be automapped since there are multiple Single relationships on class '"
+ this.PropertyWrapper.RelatedClassType + "' that reference the BusinessObject Class '"
+ this.PropertyWrapper.DeclaringClassName + "'. Please map using ClassDef.XML or Attributes");
}
var relationshipAttribute = this.PropertyWrapper.GetAttribute<AutoMapOneToManyAttribute>();
MultipleRelationshipDef relDef;
if (propertyType.IsGenericType)
{
var relatedClassType = this.PropertyWrapper.RelatedClassType.UnderlyingType;
relDef = new MultipleRelationshipDef(this.PropertyWrapper.Name, relatedClassType, new RelKeyDef(), true, "", DeleteParentAction.Prevent);
}else
{
string className = StringUtilities.Singularize(this.PropertyWrapper.Name);
relDef = new MultipleRelationshipDef(this.PropertyWrapper.Name, this.PropertyWrapper.AssemblyQualifiedName, className
, new RelKeyDef(), true, "", DeleteParentAction.Prevent);
}
if(relationshipAttribute != null)
{
relDef.RelationshipType = relationshipAttribute.RelationshipType;
DeleteParentAction deleteParentAction = relationshipAttribute.DeleteParentAction;
relDef.DeleteParentAction = deleteParentAction;
}
relDef.ReverseRelationshipName = GetReverseRelationshipName();
var relPropDef = CreateRelPropDef();
relDef.RelKeyDef.Add(relPropDef);
return relDef;
}
/// <summary>