【问题标题】:Glass Mapper: Could not find a data mapper to handle property AbstractPropertyConfiguration PropertyGlass Mapper:找不到数据映射器来处理属性 AbstractPropertyConfiguration 属性
【发布时间】:2015-03-19 15:05:37
【问题描述】:

更新到 Glass.Mapper.Sc 3.2.3.50 后,我得到:

找不到数据映射器来处理属性 AbstractPropertyConfiguration 属性:Regions 类型:[type].IEventSearch Assembly:[assembly],Version=1.0.0.0,Culture=neutral,PublicKeyToken=null

第 23 行:

Line 21:             //create a context
Line 22:             Context context = Context.Create(resolver);
Line 23:             context.Load(new IConfigurationLoader[]
Line 24:             {
Line 25:                 new EventSearchMap().Load(),

整个方法:

    public void Process(PipelineArgs args)
    {
        //create the resolver
        DependencyResolver resolver = DependencyResolver.CreateStandardResolver();

        //install the custom services
        var config = new Config();
        resolver.Container.Install(new SitecoreInstaller(config));

        //create a context
        Context context = Context.Create(resolver);
        context.Load(new IConfigurationLoader[]
        {
            new EventSearchMap().Load(),
            new RegionMap().Load(),
            new MunicipalityMap().Load(),
            new SearchMap().Load(),
            new PageMap().Load(),
            new HeaderMap().Load(),
            new SectionMenuMap().Load(),
            new BreadcrumbMap().Load(),
            new NavigationMap().Load(),
            new SitemapMap().Load()
        });
    }

在此处触发:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <initialize>
        <processor type="[Type].GlassMapper, [assembly]" />
      </initialize>
    </pipelines>
  </sitecore>
</configuration>

接口:IEventSearch

[SitecoreType]
public interface IEventSearch : ISitecoreItem
{
    IEnumerable<IRegion> Regions { get; set; }
    IEnumerable<IMunicipality> Municipalities { get; set; }
}

EventSearchMap 类:

public class EventSearchMap
{
    public SitecoreFluentConfigurationLoader Load()
    {
        var loader = new SitecoreFluentConfigurationLoader();
        SitecoreType<IEventSearch> type = loader.Add<IEventSearch>().AutoMap();

        type.Delegate(x => x.Regions).GetValue(GetRegions);
        type.Delegate(x => x.Municipalities).GetValue(GetMunicipalities);

        return loader;
    }

    private IEnumerable<IMunicipality> GetMunicipalities(SitecoreDataMappingContext arg)
    {
        var municipalities = new List<IMunicipality>();
        foreach (IRegion region in GetRegions(arg))
        {
            region.Municipalities.ForEach(municipalities.Add);
        }
        return municipalities.OrderBy(x => x.Title, StringComparer.CurrentCultureIgnoreCase);
    }

    private IEnumerable<IRegion> GetRegions(SitecoreDataMappingContext arg)
    {
        var context = new Context();
        return from region in context.EventSearchPage.Children
            select arg.Service.Cast<IRegion>(region);
    }
}

【问题讨论】:

  • 能否告诉我您使用的是哪个版本的 Glass.Mapper.Sc.CastleWindsor?最新版本是 3.3.0.25。

标签: sitecore glass-mapper


【解决方案1】:

你的评论迈克尔,让我走上正确的道路。

解决方案是将 Glass.Mapper.Sc.CastleWindsor 更新到 3.3.0.25。 我在 3.2.1.23。

但是我之前尝试过:

PM> Update-Package Glass.Mapper.Sc.CastleWindsor
No updates available for 'Glass.Mapper.Sc.CastleWindsor' in project 'Core'.

但正如您所见,它说“没有可用的更新”。

解决办法是:

Install-Package Glass.Mapper.Sc.CastleWindsor -version 3.3.0.25

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多