views:

24

answers:

1
using SubSonic3 SimpleRepository;

I have a table used for an email queue which has a SentOn DATETIME column that allows nulls. Using the following Lambda expressions have yielded me errors, does anyone have any ideas how to select a list from the table were the column is null.

IList<Email> emails = _repo.Find<Email>(x => x.SentOn == null);
IList<Email> emails = _repo.Find<Email>(x => !x.SentOn.HasValue);
IList<Email> emails = _repo.Find<Email>(x => x.SentOn.Value.Equals(null));

Surely there is a simple way to achieve this, not like it's a edge case. I think my limited lambda/linq knowledge is the problem here.

A: 

Without knowing the error you encounter I'm guessing it is because you are writing LINQ code to be executed by C# but you are passing it to SubSonic to convert it into SQL.

A solution is in this question which basically involves querying the SQL db for all results then using a LINQ query within C# after.

Alternatively you should be able to do a (pseudocode) .Where(fieldName).IsNull similar to SubSonic 2.0

Graphain