Sitecore 8.2 Glass Mapper创建项目错误
我们最近将项目升级为在Sitecore 8.2,Rev3上运行,作为升级的一部分,我们必须更新现在在4.3.4.197版本上运行的Glass Mapper。Sitecore 8.2 Glass Mapper创建项目错误
然而,我们现在越来越试图创建一个项目时的错误:
var service = new SitecoreService(_database);
service.Create(parent, redHotDeal);
我们得到唯一的例外是: 无法找到父项目类型Sitecore.Data.Items.Item配置
堆栈跟踪:
在Glass.Mapper.Sc.SitecoreService.Create [T,TK](TK父,T的newitem,布尔updateStatistics,布尔无声)在C:\ TeamCity的\ buildAgent \工作\ 8567e2ba106d3992 \ Source \ Glass.Mapper.Sc \ SitecoreService.cs:第200行 位于G:\ TFSProjects \ IV \ Source中的TTC.IV.Infrastructure.Import.RedHotDeals.RedHotDealsImporter.ImportRedHotDeals(IEnumerable`1 redhotdeals,Item parent) \ TTC.IV.Infrastructure \ Import \ RedHotDeals \ RedHotDealsImporter.cs:104行
有没有人遇到过这个问题或者知道可能是什么原因造成的?在设置
多一点信息: 父项的类型Sitecore.Data.Items.Item redHotDeal项目的类型DealCollectionItem的
DealCollectionItem模式是这样的:
使用系统; using 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; }
}
}
这现在已经得到解决。我按照https://github.com/mikeedwards83/Glass.Mapper/issues/305的建议进行了操作,并通过调用Item来将Item映射为属性,并让它自动映射。