Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight 4.0 如何在linq查询中检查可为空的日期_Silverlight 4.0_C# 4.0 - Fatal编程技术网

Silverlight 4.0 如何在linq查询中检查可为空的日期

Silverlight 4.0 如何在linq查询中检查可为空的日期,silverlight-4.0,c#-4.0,Silverlight 4.0,C# 4.0,我有一个employee类型的对象数组 var s = from x in employee where !string.IsNullOrEmpty(x.FirstName) && (x.FirstName.IndexOf(searchText, StringComparison.OrdinalIgnoreCase)) >= 0 || !string.IsNullOrEmpty(x.LastName) &

我有一个employee类型的对象数组

    var s = from x in employee
                            where !string.IsNullOrEmpty(x.FirstName) && (x.FirstName.IndexOf(searchText, StringComparison.OrdinalIgnoreCase)) >= 0 || !string.IsNullOrEmpty(x.LastName) && (x.LastName.IndexOf(searchText, StringComparison.OrdinalIgnoreCase)) >= 0 ||

//I want to check here for null DateOfBirth   
x.DateOfBirth.Value.ToShortDateString().StartsWith(searchText, StringComparison.OrdinalIgnoreCase)
                            select x;

我想你只需要

&& x.DateOfBirth.HasValue &&
添加到where子句中以过滤掉空的DOB

我假设DateOfBirth是一个可为空的DateTime