Hi, We are having an issue in Linq2SQL, querying objects on a Nullable Enum Field. Version: Dataobjects V4.4.2.8482 Description: If an entity has a NULL value for its nullable enum field, this entity won't appear in a query retrieving all values different from one of the enum value. How to reproduce : - Create an entity with a nullable enum field ([Field] public Category? Category {get;set;}), with its value set to null - Query all entities where Category != Category.MyCategory : the query doesn't return the entity with null category (session.Query.All<myentity>.Where(e=>e.Category != Category.MyCategory). Source code to reproduce : File: MyEntity.cs
File: Program.cs
Is this a bug in Dataobjects Linq2SQL ? Thanks, Benoit |
Hello Benoit, This is a tri-logic feature of SQL.
Each logical expression can be either When implementing any LINQ -> SQL translator implementor has to deal with such logic. DataObjects.Net follows LINQ To SQL (System.Data.Linq) and EF apporach to handle such cases "as is". Adding However comparing column with parameter that can have
This will be translated to For your case I suggest a workaround by adding Bonus chatter: Almost all logical operations with
|
Thanks it makes sense. So this is not a bug but a SQL feature. -> Our plan is going to be to remove Nullable<enum> everywhere and add the 'undefined'-like enum entry where necessary. |