Reputation: 21
Is this a bug in Entity Framework 6.1.1 ?
When I run the following Linq query I don't get any results.
var emptyGroups = context.ActiveDirectoryUsersGroupsStagings
.Where( x => x.GroupId == null).ToList( );
However, running the following SQL query. I do get results (7 records).
select * from ActiveDirectoryUsersGroupsStagings
where GroupId is null
Here's the table structure ...
CREATE TABLE [dbo].[ActiveDirectoryUsersGroupsStagings](
[UserId] [uniqueidentifier] NULL,
[GroupId] [uniqueidentifier] NULL,
[distinguishedName] [nvarchar](400) NULL,
[name] [nvarchar](150) NULL,
[Id] [uniqueidentifier] NOT NULL,
CONSTRAINT [PK_ActiveDirectoryUsersGroupsStagings] PRIMARY KEY CLUSTERED
(
[Id] ASC
)
Upvotes: 2
Views: 605
Reputation: 4379
Not sure if this is the case but have you tried modifying your linq query to compare the GroupId property to Guid.Empty?
var emptyGroups = context.ActiveDirectoryUsersGroupsStagings
.Where( x => !x.GroupId.HasValue).ToList( );
Upvotes: 1