question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NHibernate sample

See original GitHub issue

I really like your idea of converting GraphQL to IQueryable and have been trying to do a sample using NHibernate.

Do you know any reason why this wouldn’t work with NHibernate.

I get following exception in Executor.cs. I am on .Net 4.5 using NHibernate 4

NHibernate.Exceptions.GenericADOException was unhandled HResult=-2146232832 Message=Could not execute query[SQL: SQL not available] Source=NHibernate SqlString=SQL not available StackTrace: at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) at NHibernate.Impl.AbstractSessionImpl.List(IQueryExpression queryExpression, QueryParameters parameters) at NHibernate.Impl.AbstractQueryImpl2.List() at NHibernate.Linq.DefaultQueryProvider.ExecuteQuery(NhLinqExpression nhLinqExpression, IQuery query, NhLinqExpression nhQuery) at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression) at Remotion.Linq.QueryableBase1.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at GraphQL.Net.Executor1.Execute(TContext context, GraphQLField field, ExecSelection1 query) in C:\scratch\graphql-net\GraphQL.Net\Executor.cs:line 56 at GraphQL.Net.Executor1.Execute(GraphQLSchema1 schema, GraphQLField field, ExecSelection1 query) in C:\scratch\graphql-net\GraphQL.Net\Executor.cs:line 17 at GraphQL.Net.GraphQL1.ExecuteQuery(String queryStr) in C:\scratch\graphql-net\GraphQL.Net\GraphQL.cs:line 44 at QueryApi.Program.Program.Main(String[] args) in C:\scratch\QueryApi\QueryApi\Program\Program.cs:line 21 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() **InnerException: HResult=-2146233075 Message=Operation could destabilize the runtime. Source=Anonymously Hosted DynamicMethods Assembly StackTrace: at lambda_method(Closure , Object[] ) at NHibernate.Linq.ResultTransformer.TransformTuple(Object[] tuple, String[] aliases) at NHibernate.Hql.HolderInstantiator.Instantiate(Object[] row) at NHibernate.Loader.Hql.QueryLoader.GetResultList(IList results, IResultTransformer resultTransformer) at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet1 querySpaces, IType[] resultTypes) at NHibernate.Loader.Hql.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) at NHibernate.Impl.SessionImpl.List(IQueryExpression queryExpression, QueryParameters queryParameters, IList results) InnerException:`**

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
chkimescommented, Oct 3, 2016

Looks like it all boils down to this issue:

https://nhibernate.jira.com/browse/NH-3665

NHibernate has apparently ignored it for the past two years (I don’t know how, that seems like a very common way to write a query), so I don’t expect them to fix it anytime soon. From my investigations, I actually think it is a problem with Remotion, the library that converts LINQ into a more manageable AST.

I have figured out a workaround, though. Calling .Take(1).ToList().FirstOrDefault() instead of just .FirstOrDefault() will bypass this problem for NHibernate. I’ll do some more testing on it and if it fixes the issue I’ll incorporate it by sniffing the queryable provider for NHibernate and applying the workaround.

0reactions
efarrcommented, Sep 22, 2017

@gursharan001, Did you ever create your sample app working against NHibernate? Is it available somewhere? Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Your first NHibernate based application
This tutorial will talk you through the following: Installing NHibernate; Defining a simple business object class. Create an NHibernate mapping ...
Read more >
NHibernate - Learning with Code Samples
NHibernate automatically maps objects to the database so you can concentrate on more important matters. On this page we'll explore using ...
Read more >
NHibernate Tutorial
It is an elementary tutorial and you can easily understand the concepts explained here with a basic knowledge of how to map .NET...
Read more >
NHibernate Made Simple
A simple, straightforward tutorial that will get you up to speed on the fundamentals of NHibernate as quickly as possible.
Read more >
Learn What is NHibernate in C# with Example?
NHibernate is a very popular fully-featured tool that can be used as a solution for object-relational mapping in the .Net platform of Microsoft....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found