public static string GetCascade(ColumnSchema column, AssociationTypeEnum association) { var ep = column.ExtendedProperties["cs_cascade"]; if (ep != null && ep.Value != null) { var eps = ep.Value.ToString(); if (!String.IsNullOrEmpty(eps)) { return(eps); } } if (association == AssociationTypeEnum.OneToMany) { return(column.AllowDBNull ? "all" : "all-delete-orphan"); } if (association == AssociationTypeEnum.ManyToMany) { return("save-update"); } return(String.Empty); }
public EntityAssociation(AssociationTypeEnum associationType, TableSchema table, ColumnSchema column) : base(column) { ToManyTableKeyName = (associationType == AssociationTypeEnum.ManyToMany) ? GetToManyTableKey(column.Table, table).Name : String.Empty; Cascade = NHibernateHelper.GetCascade(column, associationType); ClassName = NHibernateHelper.GetClassName(table); AssociationType = associationType; GenericName = GetGenericName(table, Column, AssociationType); }
/// <summary> /// Converts a AssociationTypeEnum value to a corresponding string value /// </summary> /// <param name="enumValue">The AssociationTypeEnum value to convert</param> /// <returns>The representative string value</returns> public static string ToValue(AssociationTypeEnum enumValue) { switch (enumValue) { //only valid enum elements can be used //this is necessary to avoid errors case AssociationTypeEnum.ISCHILDOF: case AssociationTypeEnum.ISPEEROF: case AssociationTypeEnum.ISPARTOF: case AssociationTypeEnum.EXACTMATCHOF: case AssociationTypeEnum.PRECEDES: case AssociationTypeEnum.ISRELATEDTO: case AssociationTypeEnum.REPLACEDBY: case AssociationTypeEnum.EXEMPLAR: case AssociationTypeEnum.HASSKILLLEVEL: return(stringValues[(int)enumValue]); //an invalid enum value was requested default: return(null); } }
private string GetGenericName(TableSchema table, ColumnSchema column, AssociationTypeEnum associationType) { return(GetGenericName(table, column, (associationType != AssociationTypeEnum.ManyToOne))); }