/// <summary> /// This method is used in the Template to get the C# Collection type name for the CollectionType of the given reference. /// </summary> /// <param name="reference"></param> /// <returns></returns> public static string GetCollectionType(DirectedReference reference) { switch (GetAssociationType(reference)) { case AssociationType.None: //throw new ArgumentException("Reference " + reference.Reference.Name + " does not have an association type for End" + (reference.Entity1IsFromEnd ? "1" : "2")); return("XXXXXX"); case AssociationType.Map: // {0} should be the primary key column type, {1} is the entity type. //return string.Format("System.Collections.Generic.IDictionary<{0}, {1}>", // GetIndexColumnTypeName(reference, EntityMapper.GetPrimaryTable(reference.FromEntity)), // reference.FromEntity.Name.GetCSharpFriendlyIdentifier()); return(string.Format("IDictionary<{0}, {1}>", GetIndexColumnTypeName(reference, EntityMapper.GetPrimaryTable(reference.ToEntity)), reference.ToEntity.Name)); case AssociationType.List: case AssociationType.Bag: //return string.Format("System.Collections.Generic.IList<{0}>", reference.ToEntity.Name.GetCSharpFriendlyIdentifier()); return(string.Format("IList<{0}>", reference.ToEntity.Name)); case AssociationType.Set: //return string.Format("Iesi.Collections.Generic.ISet<{0}>", reference.ToEntity.Name.GetCSharpFriendlyIdentifier()); return(string.Format("Iesi.Collections.Generic.ISet<{0}>", reference.ToEntity.Name)); //case AssociationType.IDBag: // Should this also be an IDictionary? // throw new NotImplementedException("Have not implemented IDBag types yet."); case AssociationType.IDBag: return(string.Format("Iesi.Collections.Generic.ISet<{0}>", reference.ToEntity.Name)); default: throw new NotImplementedException("Collection type not handled yet in GetCollectionType(): " + GetAssociationType(reference)); } }