Hi All,
I have a fairly simple NHibernate.Linq query that throws an error when
I enable query caching - is this a known issue? Or am I just doing
something stupid?
Here's the exact code causing the issue...
var querySource = Linq<Entry>();
//comment out this line and everything works fine
querySource.QueryOptions.SetCachable(true);
//this throws the exception
var results = (from e in querySource
where e.Type == EntryType.Page
orderby e.Title
select new MenuItem { Id = e.Id, Title = e.Title,
Slug = e.Slug, Type = e.Type })
.ToList();
The exception is...
Unable to cast object of type 'Cuvinte.Plugins.Widgets.Menu.MenuItem'
to type 'System.Object[]'.
[InvalidCastException: Unable to cast object of type
'Cuvinte.Plugins.Widgets.Menu.MenuItem' to type 'System.Object[]'.]
NHibernate.Cache.StandardQueryCache.Put(QueryKey key,
ICacheAssembler[] returnTypes, IList result, Boolean
isNaturalKeyLookup, ISessionImplementor session) +282
NHibernate.Loader.Loader.PutResultInQueryCache(ISessionImplementor
session, QueryParameters queryParameters, IType[] resultTypes,
IQueryCache queryCache, QueryKey key, IList result) +51
NHibernate.Loader.Loader.ListUsingQueryCache(ISessionImplementor
session, QueryParameters queryParameters, ISet`1 querySpaces, IType[]
resultTypes) +180
NHibernate.Loader.Loader.List(ISessionImplementor session,
QueryParameters queryParameters, ISet`1 querySpaces, IType[]
resultTypes) +60
NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList
results) +348
[GenericADOException: Unable to perform find[SQL: SQL not available]]
NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList
results) +417
NHibernate.Impl.CriteriaImpl.List(IList results) +41
NHibernate.Impl.CriteriaImpl.List() +34
NHibernate.Linq.<GetEnumerator>d__0.MoveNext() +71
System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
+7667732
System.Linq.Enumerable.ToList(IEnumerable`1 source) +61
Cuvinte.Plugins.Widgets.Menu.MenuService.GetMenu(Int32[] include,
Int32[] exclude) in d:\Home\desktop\Cuvinte\trunk\src\Cuvinte\Plugins
\Widgets\Menu\MenuService.cs:34
Cuvinte.Plugins.Widgets.Menu.MenuWidgetController.Index(String
include, String exclude, Nullable`1 home) in d:\Home\desktop\Cuvinte
\trunk\src\Cuvinte\Plugins\Widgets\Menu\MenuWidgetController.cs:13
lambda_method(ExecutionScope , ControllerBase , Object[] ) +166
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase
controller, Object[] parameters) +17
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext
controllerContext, IDictionary`2 parameters) +178
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod
(ControllerContext controllerContext, ActionDescriptor
actionDescriptor, IDictionary`2 parameters) +24
System.Web.Mvc.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7
() +52
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter
(IActionFilter filter, ActionExecutingContext preContext, Func`1
continuation) +254
System.Web.Mvc.<>c__DisplayClassc.<InvokeActionMethodWithFilters>b__9
() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters
(ControllerContext controllerContext, IList`1 filters,
ActionDescriptor actionDescriptor, IDictionary`2 parameters) +192
Cuvinte.Framework.WindsorActionInvoker.InvokeActionMethodWithFilters
(ControllerContext controllerContext, IList`1 filters,
ActionDescriptor actionDescriptor, IDictionary`2 parameters) in d:\Home
\desktop\Cuvinte\trunk\src\Cuvinte\Domain\Infrastructure
\WindsorActionInvoker.cs:19
System.Web.Mvc.ControllerActionInvoker.InvokeAction
(ControllerContext controllerContext, String actionName) +399
System.Web.Mvc.Controller.ExecuteCore() +126
System.Web.Mvc.ControllerBase.Execute(RequestContext
requestContext) +27
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute
(RequestContext requestContext) +7
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
httpContext) +151
Microsoft.Web.Mvc.ViewExtensions.RenderRoute(HtmlHelper helper,
RouteValueDictionary routeValues) +214
Microsoft.Web.Mvc.ViewExtensions.RenderAction(HtmlHelper helper,
String actionName, String controllerName, RouteValueDictionary
routeValues) +315
Microsoft.Web.Mvc.ViewExtensions.RenderAction(HtmlHelper helper,
String actionName, String controllerName, Object routeValues) +45
Cuvinte.Framework.Widgets.WidgetExtensions.RenderWidget(HtmlHelper
helper, String widgetName, String action, Object data) in d:\Home
\desktop\Cuvinte\trunk\src\Cuvinte\Domain\Infrastructure\Widgets
\WidgetExtensions.cs:29
ASP.plugins_themes_default_site_master.__Render__control1
(HtmlTextWriter __w, Control parameterContainer) in d:\Home\desktop
\Cuvinte\trunk\src\Cuvinte\Plugins\Themes\Default\Site.Master:42
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +256
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +59
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1266
And, finally, according to Reflector this is the code around where the
exception is happening...
public bool Put(QueryKey key, ICacheAssembler[] returnTypes, IList
result, bool isNaturalKeyLookup, ISessionImplementor session)
{
if (isNaturalKeyLookup && (result.Count == 0))
{
return false;
}
long timestamp = session.Timestamp;
if (log.IsDebugEnabled)
{
log.DebugFormat("caching query results in region: '{0}'; {1}",
this.regionName, key);
}
List<object> list2 = new List<object>(result.Count + 1);
list2.Add(timestamp);
IList list = list2;
for (int i = 0; i < result.Count; i++)
{
if (returnTypes.Length == 1)
{
list.Add(returnTypes[0].Disassemble(result[i], session,
null));
}
else
{
//I assume this is the line....
list.Add(TypeFactory.Disassemble((object[]) result[i],
returnTypes, null, session, null));
}
}
this.queryCache.Put(key, list);
return true;
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---