Fixes issue with duplicate dictionary entries when wiring up property data

This commit is contained in:
Shannon
2014-09-01 12:55:10 +10:00
parent 8b9397160b
commit 07035f6b23
3 changed files with 34 additions and 9 deletions

1
.gitignore vendored
View File

@@ -120,3 +120,4 @@ src/Umbraco.Web.UI.Client/bower_components/*
#Ignore Rule for output of generated documentation files from Grunt docserve
src/Umbraco.Web.UI.Client/docs/api
src/*.boltdata/

View File

@@ -28,5 +28,23 @@ namespace Umbraco.Core.Models.Rdbms
[NullSetting(NullSetting = NullSettings.Null)]
[Length(50)]
public string Alias { get; set; }
protected bool Equals(DataTypePreValueDto other)
{
return Id == other.Id;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((DataTypePreValueDto) obj);
}
public override int GetHashCode()
{
return Id;
}
}
}

View File

@@ -292,15 +292,18 @@ namespace Umbraco.Core.Persistence.Repositories
SortOrder = x.sortorder,
Value = x.value
})
.ToDictionary(x => x.Alias, x => new PreValue(x.Id, x.Value, x.SortOrder));
.Distinct()
.ToArray();
var preVals = new PreValueCollection(preValData);
var asDictionary = preValData.ToDictionary(x => x.Alias, x => new PreValue(x.Id, x.Value, x.SortOrder));
var d = new ContentPropertyData(property.Value,
var preVals = new PreValueCollection(asDictionary);
var contentPropData = new ContentPropertyData(property.Value,
preVals,
new Dictionary<string, object>());
TagExtractor.SetPropertyTags(property, d, property.Value, tagSupport);
TagExtractor.SetPropertyTags(property, contentPropData, property.Value, tagSupport);
}
}
@@ -386,15 +389,18 @@ namespace Umbraco.Core.Persistence.Repositories
SortOrder = x.sortorder,
Value = x.value
})
.ToDictionary(x => x.Alias, x => new PreValue(x.Id, x.Value, x.SortOrder));
.Distinct()
.ToArray();
var preVals = new PreValueCollection(preValData);
var asDictionary = preValData.ToDictionary(x => x.Alias, x => new PreValue(x.Id, x.Value, x.SortOrder));
var d = new ContentPropertyData(property.Value,
var preVals = new PreValueCollection(asDictionary);
var contentPropData = new ContentPropertyData(property.Value,
preVals,
new Dictionary<string, object>());
TagExtractor.SetPropertyTags(property, d, property.Value, tagSupport);
TagExtractor.SetPropertyTags(property, contentPropData, property.Value, tagSupport);
}
}