public static ForeignKeyDefinition GetForeignKeyDefinition(Type modelType, PropertyInfo propertyInfo, ForeignKeyAttribute attribute, string columnName, string tableName) { var referencedTable = attribute.Type.FirstAttribute <TableNameAttribute>(); var referencedPrimaryKey = attribute.Type.FirstAttribute <PrimaryKeyAttribute>(); string referencedColumn = string.IsNullOrEmpty(attribute.Column) ? referencedPrimaryKey.Value : attribute.Column; string foreignKeyName = string.IsNullOrEmpty(attribute.Name) ? string.Format("FK_{0}_{1}_{2}", tableName, referencedTable.Value, referencedColumn) : attribute.Name; var definition = new ForeignKeyDefinition { Name = foreignKeyName, ForeignTable = tableName, PrimaryTable = referencedTable.Value, OnDelete = attribute.OnDelete, OnUpdate = attribute.OnUpdate }; definition.ForeignColumns.Add(columnName); definition.PrimaryColumns.Add(referencedColumn); return(definition); }
public static ForeignKeyDefinition GetForeignKeyDefinition(Type modelType, PropertyInfo propertyInfo, ForeignKeyAttribute attribute, string columnName, string tableName) { var referencedTable = attribute.Type.FirstAttribute<TableNameAttribute>(); var referencedPrimaryKey = attribute.Type.FirstAttribute<PrimaryKeyAttribute>(); string referencedColumn = string.IsNullOrEmpty(attribute.Column) ? referencedPrimaryKey.Value : attribute.Column; string foreignKeyName = string.IsNullOrEmpty(attribute.Name) ? string.Format("FK_{0}_{1}_{2}", tableName, referencedTable.Value, referencedColumn) : attribute.Name; var definition = new ForeignKeyDefinition { Name = foreignKeyName, ForeignTable = tableName, PrimaryTable = referencedTable.Value }; definition.ForeignColumns.Add(columnName); definition.PrimaryColumns.Add(referencedColumn); return definition; }
public DeleteForeignKeyExpression(DatabaseProviders current, DatabaseProviders[] databaseProviders) : base(current, databaseProviders) { ForeignKey = new ForeignKeyDefinition(); }
public DeleteForeignKeyExpression() { ForeignKey = new ForeignKeyDefinition(); }
public CreateForeignKeyExpression() { ForeignKey = new ForeignKeyDefinition(); }