Refactoring identity inserts in db creation phase to support mysql

This commit is contained in:
Morten Christensen
2012-12-05 14:18:08 -01:00
parent e31fc6e86a
commit 8210666d30
4 changed files with 49 additions and 51 deletions

View File

@@ -28,6 +28,10 @@ namespace Umbraco.Core.Persistence.SqlSyntax.ModelDefinitions
var columnAttribute = propertyInfo.FirstAttribute<ColumnAttribute>();
string columnName = columnAttribute != null ? columnAttribute.Name : propertyInfo.Name;
//Use PetaPoco's PrimaryKeyAttribute to set Identity property on TableDefinition
var primaryKeyAttribute = modelType.FirstAttribute<PrimaryKeyAttribute>();
tableDefinition.IsIdentity = primaryKeyAttribute != null && primaryKeyAttribute.autoIncrement;
//Creates a column definition and adds it to the collection on the table definition
var columnDefinition = new ColumnDefinition
{

View File

@@ -13,6 +13,7 @@ namespace Umbraco.Core.Persistence.SqlSyntax.ModelDefinitions
}
public string TableName { get; set; }
public bool IsIdentity { get; set; }
public bool IsPrimaryKeyClustered
{
get { return ColumnDefinitions.Any(x => x.IsPrimaryKeyClustered); }