Ensures that the ContentBase item is set on Document/Media and that the property value is set based on the already loaded value in the model if IData implements IDataValueSetter (which DefaultData does). This streamlines how properties get their data and will save on a ton of queries when using the legacy API.

This commit is contained in:
Shannon
2013-12-05 14:26:18 +11:00
parent 38df2017de
commit e6d8a83519
3 changed files with 14 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ using umbraco.DataLayer;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.datatype;
using umbraco.cms.businesslogic.propertytype;
using umbraco.interfaces;
namespace umbraco.cms.businesslogic.property
{
@@ -61,6 +62,14 @@ namespace umbraco.cms.businesslogic.property
_pt = PropertyType.GetPropertyType(property.PropertyTypeId);
_data = _pt.DataTypeDefinition.DataType.Data;
_data.PropertyId = Id;
//set the value so it doesn't need to go to the database
var dvs = _data as IDataValueSetter;
if (dvs != null)
{
dvs.SetValue(property.Value, property.PropertyType.DataTypeDatabaseType.ToString());
}
}
public Guid VersionId

View File

@@ -380,6 +380,8 @@ namespace umbraco.cms.businesslogic.media
private void SetupNode(IMedia media)
{
MediaItem = media;
//Also need to set the ContentBase item to this one so all the propery values load from it
ContentBase = MediaItem;
//Setting private properties from IContentBase replacing CMSNode.setupNode() / CMSNode.PopulateCMSNodeFromReader()
base.PopulateCMSNodeFromUmbracoEntity(MediaItem, _objectType);

View File

@@ -1428,6 +1428,9 @@ namespace umbraco.cms.businesslogic.web
private void SetupNode(IContent content)
{
Content = content;
//Also need to set the ContentBase item to this one so all the propery values load from it
ContentBase = Content;
//Setting private properties from IContentBase replacing CMSNode.setupNode() / CMSNode.PopulateCMSNodeFromReader()
base.PopulateCMSNodeFromUmbracoEntity(Content, _objectType);