我们最近将我们的项目升级为在Sitecore 8.2,Rev3上运行,作为升级的一部分,我们必须更新现在在4.3.4.197版本上运行的Glass Mapper。
但是,我们现在在尝试创建项目时遇到错误:
var service = new SitecoreService(_database);
service.Create(parent, redHotDeal);
我们得到的例外是: 无法找到父项类型Sitecore.Data.Items.Item的配置
堆栈跟踪:
在C:\ TeamCity \ buildAgent \ work \ 8567e2ba106d3992 \ Source \ Glass.Mapper.Sc中的Glass.Mapper.Sc.SitecoreService.Create [T,TK](TK parent,T newItem,Boolean updateStatistics,Boolean silent) \ SitecoreService.cs:第200行 at TTC.IV.Infrastructure.Import.RedHotDeals.RedHotDealsImporter.ImportRedHotDeals(IEnumerable`1 redhotdeals,Item parent)在G:\ TFSProjects \ IV \ Source \ TTC.IV.Infrastructure \ Import \ RedHotDeals \ RedHotDealsImporter.cs:第104行< / p>
是否有人遇到此问题或知道可能导致此问题的原因?
有关设置的更多信息: 父项的类型为Sitecore.Data.Items.Item redHotDeal项目的类型为DealCollectionItem
DealCollectionItem模型如下所示:
使用System; 使用Glass.Mapper.Sc.Configuration.Attributes;
namespace TTC.IV.Model.Templates.Items
{
[SitecoreType(TemplateId = TemplateStringId)]
public class DealCollectionItem : Item
{
public new static Guid TemplateId = new Guid(TemplateStringId);
private const string TemplateStringId = "{998CA212-92D5-4566-B877-44D1F378EFD6}";
/// <summary>
/// Gets or sets the mv code.
/// </summary>
/// <value>
/// The mv code.
/// </value>
[SitecoreField]
public virtual string MvCode { get; set; }
/// <summary>
/// Gets or sets the departure code.
/// </summary>
/// <value>
/// The departure code.
/// </value>
[SitecoreField]
public virtual string DepartureCode { get; set; }
/// <summary>
/// Gets or sets the discount.
/// </summary>
/// <value>
/// The discount.
/// </value>
[SitecoreField]
public virtual double Discount { get; set; }
/// <summary>
/// Gets or sets the promo code.
/// </summary>
/// <value>
/// The promo code.
/// </value>
[SitecoreField]
public virtual string PromoCode { get; set; }
/// <summary>
/// Gets or sets the price.
/// </summary>
/// <value>
/// The price.
/// </value>
[SitecoreField]
public virtual double Price { get; set; }
/// <summary>
/// Gets or sets the promo amount.
/// </summary>
/// <value>
/// The promo amount.
/// </value>
[SitecoreField]
public virtual double PromoAmount { get; set; }
/// <summary>
/// Gets or sets the table amount.
/// </summary>
/// <value>
/// The table amount.
/// </value>
[SitecoreField]
public virtual int TableAmount { get; set; }
/// <summary>
/// Gets or sets the import region.
/// </summary>
/// <value>
/// The import region.
/// </value>
public string ImportRegion { get; set; }
}
}
答案 0 :(得分:0)
现在已经解决了。我按照https://github.com/mikeedwards83/Glass.Mapper/issues/305按照建议进行了操作,并将Item作为属性映射为“Item”并让它自动化。