New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VB Linq query on nullable column throws sql exception #318
Comments
post a little bit more of your c# code, i think you doing it wrong in c#! wich version are you using? newest git? |
Full C# code:
Full VB Code:
SearchCondition3 is being called from the |
i think in c# you should also write db.Order, or where does this order field com from? Von meinem iPhone gesendet
|
Ha! Very good catch. That makes the
The |
maybe you need to look the expression wich will be created in the debugger, in vs2013 you can display expression trees, and look whats different. or use this http://exprtreevisualizer.codeplex.com Von meinem iPhone gesendet
|
Grabbed the generated expression tree from the C#
VB
The only difference I am seeing is the |
maybe than your error is a compiler error, since i think same code should return the same expression! maybe you ask on stack overflow if there is a bug known, or if its a bug in our understanding! if its a vb bug, maybe open a ticket at microsoft connect Von meinem iPhone gesendet
|
Good idea, Ill ask on stack overflow to see if anyone else has seen this. Thanks for your help so far, didn't know you could log the expression tree like that. |
Question asked here. |
Someone answered my question on stack overflow, looks like this is bizarre handling for legacy VB code. Can BLToolkit be updated to handle this? |
Maybe you also create a issue at https://github.com/linq2db/linq2db because it has nearly the same expression parsing code... |
Does BLToolkit use that library for expression parsing? |
no, it is a lib from the bltoolkit author also for db access! but it's much newer, and shares most of the expression parsing code |
…n when using nullable properties.
Now fails next code: Additional information: The binary operator Equal is not defined for the types 'System.Nullable`1[System.Boolean]' and 'System.Boolean'. /*
-- sql server
create table test5
(
data int null
)
*/
class test5
{
public bool? data;
}
using (var db = new DbManager())
{
var items = db.GetTable<test5>().Where(i => (i.data ?? false) == false).ToList();
} |
I am attempting to use the sample NorthwindDB order class from a
VB.Net
project. Anytime I execute a where linq query against theOrder::OrderDate
property, BLToolkit throws an exception from the SQL Server saying that there is incorrect syntax. If I remove the ? from OrderDate, making it a nonnullable property, the query executes perfectly fine.The working
C#
code:Executes this SQL on the server:
The failing
VB.Net
code:Executes this SQL on the server:
There seem to be two bugs here, first one being that the
VB.Net
expression is generating invalid sql, second one being thatC#
is doing no server side filtering. Is this a bug in BLToolkit, or am I using it incorrectly?The text was updated successfully, but these errors were encountered: