Using: Entity Framework 4.3.1, MVC 4
Sample database records (for example):
Id Height 1 null 2 2.1
Why does this first statement bring back zero results:
decimal? scannedItemHeight = default(decimal?);
(from st in Stocks
where st.Height == scannedItemHeight
select st.Id).ToList();
But this statement returns record Id 1:
(from st in Stocks
where st.Height == null
select st.Id).ToList();
If scannedItemHeight is null, I only want to match values where the height is null too.
I only want to return the first record, Id 1.
UPDATE I ended up using:
st.Height == scannedItemHeight || (scannedItemHeight == null && st.Height == null)