score:2
Ok, found the solution. Nothing wrong with mapping etc., just with how the LINQ query is translated to SQL. In particular, how this line is translated:
&& item.IsActive == true
Somehow, this gets translated into the complex CASE-statement which ultimately results in the exception message. However, the == true
-part isn't really necessary. By removing it, the translator no longer gets confused and provides the proper SQL:
factuurite0_.IsActive=1
No more CASE-statement and no more exception.
score:1
Using Log4Net at the debug level? In some version of Hibernate and Log4Net there is an incompatibility when turn on logging at the DEBUG level. All you get is this error about 'unable to execute sql cannot cast boolean to string'. Try turning up your logging level to INFO and the problem should go away.
Source: stackoverflow.com
Related Articles
- nHibernate unable to cast Boolean to String
- NHibernate List - Unable to cast object of type System.Collections.Hashtable
- List or Array of String Contain specific word in Html Source Code
- Unable to cast string type to number type in Linq expression
- C# - code to order by a property using the property name as a string
- Unable to cast object of type 'System.Linq.Expressions.UnaryExpression' to type 'System.Linq.Expressions.MemberExpression'
- How to do a case-insensitive string where in NHibernate Linq query?
- Cast string as Guid using LinqPad
- Unable to cast object of type WhereSelectListIterator 2 System.Collections.Generic.List
- Unable to cast object of type 'System.Data.Linq.DataQuery`1[System.Int32]' to type 'System.IConvertible'
- Why is a collection of <enum> unable to cast to an <int?>?
- Unable to cast object of type 'WhereEnumerableIterator`1' to type 'System.Collections.Generic.ICollection`1
- Unable to cast the type 'System.Nullable`1' to type 'System.Object' - ASP.NET MVC
- Unable to cast object of type 'System.Collections.Generic.List`1[System.Decimal]' to type 'System.IConvertible'
- Why can't I cast nullable DateTime as string in a LinQ query?
- Cast Dictionary KeyCollection to String array
- Unable to cast object of type 'System.Int32' to type 'System.String'
- Unable to cast a object of type 'SZArrayEnumerator' to type 'System.Collections.Generic.IEnumerator' 1[System.String]'
- .NET String parsing performance improvement - Possible Code Smell
- Unable to cast object of type WhereSelectListIterator
- Query a byte property with nhibernate cause invalid cast error
- Unable to cast object of type 'System.Linq.EnumerableQuery to type 'Microsoft.Azure.Documents.Linq.IDocumentQuery
- LINQ Source Code Available
- Dynamic LINQ - Unable to convert between GUID and string
- Efficient way to unindent lines of code stored in a string
- Linq Unable To Cast Issue
- NHibernate querying on a string collection using Linq results in either error or empty collection
- Unable to cast object of type System.Func`2 with Int64
- .NET 4 Code Contracts: "requires unproven: source != null"
- Unable to cast object of type 'System.Data.Entity.Infrastructure.DbQuery`1[]' using linq lambda expression
- Dividing a textfile and show it into listbox, where each line in the listbox will have 30 lines of textfile seperated by comma
- Can someone explain this Linq Query?
- Excel to SQL, C# libraries
- XDocument can't load xml with version 1.1 in C# LINQ?
- Select descendent nodes and elements from an XML using LINQ
- A LINQ with XML question
- Reference class property in app.config?
- Using LINQ in C#, How to retrieve list of events based on specific dates, for example all events that are planned for upcoming 45 days?
- Update list by another list (linq)
- query not translated by in Entity Framework, .net Core 3.1
- LINQ include a subset of a query
- Get linked Object values in Linq C#
- Run an IQueryable with Entity Framework
- Using linq to compare object values works for single object but not a list of objects
- DocumentDb Spatial Distance in Linq returns weird result
- Filtering DataTable with LINQ
- Writing a method to be used as IQueryable
- Using LINQ find nearby places from database
- Linq query with 3 tables
- LINQ: Get the path in a hierarchical structure collection item