未找到 Castle ActiveRecordMediator 密钥

发布于 2024-10-01 01:42:28 字数 6264 浏览 6 评论 0原文

我在从 mvc 1 迁移到 mvc 2 时遇到问题。 在我的旧项目中,我使用了 Active Record。

现在在新项目上运行,尝试从存储库获取数据时,

      public T[] SlicedFindAll(int firstResult, int maxResult, DetachedCriteria criteria)
  {
      return ActiveRecordMediator<T>.SlicedFindAll(firstResult, maxResult, criteria);
  }

我收到错误“给定的密钥不存在于字典中。”

这是堆栈跟踪:

[KeyNotFoundException:字典中不存在给定的键。] System.Collections.Generic.Dictionary2.get_Item(TKey key) +9627953 NHibernate.Cfg.Mapping.GetPersistentClass(String className) +85 NHibernate.Cfg.Mapping.GetIdentifierType(字符串类名)+66 NHibernate.Type.EntityType.GetIdentifierType(IMapping 工厂)+84 NHibernate.Type.EntityType.GetIdentifierOrUniqueKeyType(IMapping 工厂)+112 NHibernate.Type.ManyToOneType.GetColumnSpan(IMapping 映射) +66 NHibernate.Mapping.SimpleValue.IsValid(IMapping 映射) +96 NHibernate.Mapping.ToOne.IsValid(IMapping 映射)+144 NHibernate.Mapping.Property.IsValid(IMapping 映射) +80 NHibernate.Mapping.PersistentClass.Validate(IMapping 映射)+138 NHibernate.Mapping.RootClass.Validate(IMapping 映射) +68 NHibernate.Cfg.Configuration.ValidateEntities() +246 NHibernate.Cfg.Configuration.Validate() +44 NHibernate.Cfg.Configuration.BuildSessionFactory() +86 Castle.ActiveRecord.Framework.SessionFactoryHolder.GetSessionFactory(类型类型)在 d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:135 Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateScopeSession(类型类型)在 d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:296 Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateSession(类型类型)在 d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:182 d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src 中的 Castle.ActiveRecord.ActiveRecordBase.SlicedFindAll(Type targetType, Int32 firstResult, Int32 maxResults, Order[]orders, DetachedCriteria criteria) \Castle.ActiveRecord\Framework\ActiveRecordBase.cs:1420 d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src 中的 Castle.ActiveRecord.ActiveRecordMediator.SlicedFindAll(Type targetType, Int32 firstResult, Int32 maxResults, Order[]orders, DetachedCriteria criteria) \Castle.ActiveRecord\Framework\ActiveRecordMediator.cs:185 Castle.ActiveRecord.ActiveRecordMediator1.SlicedFindAll(Int32 firstResult, Int32 maxResults, DetachedCriteria criteria, Order[]orders) in d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972 \src\Castle.ActiveRecord\Framework\ActiveRecordMediator.Generic.cs:241 Cameos.Core.Persistence.Repository1.SlicedFindAll(Int32 firstResult, Int32 maxResult, DetachedCriteria criteria) in d:\Dev\MVC2\Cameos\src\Cameos.Core\Persistence\Repository.cs:96 Cameos.Core.Paging.PagedList1..ctor(IRepository1 存储库,Int32 页面,Int32 大小,DetachedCriteria 标准)位于 d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\分页列表.cs:24 Cameos.Core.Paging.PagedList1.Create(IRepository1 存储库,Int32 页,Int32 pageSize,DetachedCriteria 标准) 在 d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\PagedList .cs:13 Cameos.Core.Paging.PaginationHelpers.Paginate(IRepository1 存储库、Int32 startPage、Int32 pageSize、DetachedCriteria 标准)位于 d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\PaginationHelpers.cs:52 Cameos.Core.Paging.PaginationHelpers.Paginate(IRepository1 存储库、Int32 startPage、Int32 pageSize、顺序 order、ICriterion[] criteria) 位于 d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\PaginationHelpers .cs:34 Cameos.Web.Areas.Admin.Controllers.CompanyController.Index(可为 Nullable1 页) 在 d:\Dev\MVC2\Cameos\src\Cameos.Web2\Areas\Admin\Controllers\CompanyController.cs:26 lambda_method(闭包,ControllerBase,对象[])+145 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,Object[]参数)+51 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContextcontrollerContext,IDictionary2个参数)+409 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContextcontrollerContext,ActionDescriptoractionDescriptor,IDictionary2个参数)+52 System.Web.Mvc.<>c_DisplayClassd.b_a() +127 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter 过滤器,ActionExecutingContext preContext,Func1 延续)+436 System.Web.Mvc.<>c__DisplayClassf.b__c() +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter过滤器,ActionExecutingContext preContext,Func1延续)+436 System.Web.Mvc.<>c_DisplayClassf.b_c() +61 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContextcontrollerContext,IList1个过滤器,ActionDescriptoractionDescriptor,IDictionary2个参数)+305 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContextcontrollerContext,字符串actionName)+830 System.Web.Mvc.Controller.ExecuteCore() +136 System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +111 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39 System.Web.Mvc.<>c_DisplayClass8.b_4() +65 System.Web.Mvc.Async。<>c_DisplayClass1.b_0() +44 System.Web.Mvc.Async。<>c__DisplayClass81.b__7(IAsyncResult _) +42 System.Web.Mvc.Async.WrappedAsyncResult1.End() +141 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,对象标签)+54 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult,对象标签)+40 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)+52 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult结果)+38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8836913 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤,Boolean&completedSynchronously) +184

I'm having problem moving from mvc 1 to mvc 2.
In my old project I used Active Record.

Now running on new project where trying to get data from reposetory

      public T[] SlicedFindAll(int firstResult, int maxResult, DetachedCriteria criteria)
  {
      return ActiveRecordMediator<T>.SlicedFindAll(firstResult, maxResult, criteria);
  }

I recive an error "The given key was not present in the dictionary."

This is a stack trace:

[KeyNotFoundException: The given key was not present in the dictionary.]
System.Collections.Generic.Dictionary2.get_Item(TKey key) +9627953
NHibernate.Cfg.Mapping.GetPersistentClass(String className) +85
NHibernate.Cfg.Mapping.GetIdentifierType(String className) +66
NHibernate.Type.EntityType.GetIdentifierType(IMapping factory) +84
NHibernate.Type.EntityType.GetIdentifierOrUniqueKeyType(IMapping factory) +112
NHibernate.Type.ManyToOneType.GetColumnSpan(IMapping mapping) +66
NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping) +96
NHibernate.Mapping.ToOne.IsValid(IMapping mapping) +144
NHibernate.Mapping.Property.IsValid(IMapping mapping) +80
NHibernate.Mapping.PersistentClass.Validate(IMapping mapping) +138
NHibernate.Mapping.RootClass.Validate(IMapping mapping) +68
NHibernate.Cfg.Configuration.ValidateEntities() +246
NHibernate.Cfg.Configuration.Validate() +44
NHibernate.Cfg.Configuration.BuildSessionFactory() +86
Castle.ActiveRecord.Framework.SessionFactoryHolder.GetSessionFactory(Type type) in d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:135
Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateScopeSession(Type type) in d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:296
Castle.ActiveRecord.Framework.SessionFactoryHolder.CreateSession(Type type) in d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\SessionFactoryHolder.cs:182
Castle.ActiveRecord.ActiveRecordBase.SlicedFindAll(Type targetType, Int32 firstResult, Int32 maxResults, Order[] orders, DetachedCriteria criteria) in d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:1420
Castle.ActiveRecord.ActiveRecordMediator.SlicedFindAll(Type targetType, Int32 firstResult, Int32 maxResults, Order[] orders, DetachedCriteria criteria) in d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\ActiveRecordMediator.cs:185
Castle.ActiveRecord.ActiveRecordMediator
1.SlicedFindAll(Int32 firstResult, Int32 maxResults, DetachedCriteria criteria, Order[] orders) in d:\Dev\Out\castleproject-Castle.ActiveRecord-b0f7972\castleproject-Castle.ActiveRecord-b0f7972\src\Castle.ActiveRecord\Framework\ActiveRecordMediator.Generic.cs:241
Cameos.Core.Persistence.Repository1.SlicedFindAll(Int32 firstResult, Int32 maxResult, DetachedCriteria criteria) in d:\Dev\MVC2\Cameos\src\Cameos.Core\Persistence\Repository.cs:96
Cameos.Core.Paging.PagedList
1..ctor(IRepository1 repository, Int32 page, Int32 size, DetachedCriteria criteria) in d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\PagedList.cs:24
Cameos.Core.Paging.PagedList
1.Create(IRepository1 repository, Int32 page, Int32 pageSize, DetachedCriteria criteria) in d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\PagedList.cs:13
Cameos.Core.Paging.PaginationHelpers.Paginate(IRepository
1 repository, Int32 startPage, Int32 pageSize, DetachedCriteria criteria) in d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\PaginationHelpers.cs:52
Cameos.Core.Paging.PaginationHelpers.Paginate(IRepository1 repository, Int32 startPage, Int32 pageSize, Order order, ICriterion[] criteria) in d:\Dev\MVC2\Cameos\src\Cameos.Core\Paging\PaginationHelpers.cs:34
Cameos.Web.Areas.Admin.Controllers.CompanyController.Index(Nullable
1 page) in d:\Dev\MVC2\Cameos\src\Cameos.Web2\Areas\Admin\Controllers\CompanyController.cs:26
lambda_method(Closure , ControllerBase , Object[] ) +145
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +51
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +409
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +52
System.Web.Mvc.<>c_DisplayClassd.b_a() +127
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +436
System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +61
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func
1 continuation) +436
System.Web.Mvc.<>c_DisplayClassf.b_c() +61
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters) +305
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +830
System.Web.Mvc.Controller.ExecuteCore() +136
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +111
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +39
System.Web.Mvc.<>c_DisplayClass8.b_4() +65
System.Web.Mvc.Async.<>c_DisplayClass1.b_0() +44
System.Web.Mvc.Async.<>c__DisplayClass81.<BeginSynchronous>b__7(IAsyncResult _) +42
System.Web.Mvc.Async.WrappedAsyncResult
1.End() +141
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +54
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +52
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8836913
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

二智少女 2024-10-08 01:42:28

[BelongsTo] 配置错误。

A [BelongsTo] is misconfigured.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文