This has to be very simple but for the life of me I cannot get the solution.
I have a WPF DatePicker and want to use the selected date in a Linq query i.e. I want to query an SQL Server table using the WPF DatePicker date.
The column I want to query is called recordedtime and the DatePicker is called dpLatestDate.
private void cmd_GetDates_Click(object sender, RoutedEventArgs e)
{
Linq_PackageLogsDataContext LP = new Linq_PackageLogsDataContext();
var findDates = from n in LP.tblPackageLogs
where n.recordedtime = dpLatestDate(??What goes here??)
select n;
GridDate.ItemsSource = findDates;
}
Thanks for your time.
Cheers
C

VulpesPosted Feb 3, 2012, 3:01 PM
That clause should be:
where n.recordedtime == dpLatestDate.SelectedDate
VulpesPosted Feb 3, 2012, 3:36 PM
C BPosted Feb 3, 2012, 3:12 PM
I'm the one who should be goind Doh. I am a newbie but I do have some experience with C# and should have worked that one out.
However, in my defence, I spent the morning working with VBA and you only use the singe '='. So I was still in VBA mode, thats my excuse and I am sticking to it. I can stop swearing at my computer and relax.
My phrase rings very true "Its only bloody obvious when you know how!"
Thanks for your time.
Cheers
C
C BPosted Feb 3, 2012, 9:05 AM
Thanks Vulpes
I have tried this and got an error i.e. Cannot implicitly convert type 'System.DateTime?' to 'bool'.
I have checked the SQL server and the column is set at recordedtime (datetime, null). At the moment I am a bit lost.
Thanks for your time.
VulpesPosted Feb 3, 2012, 8:49 AM
where n.recordedtime = dpLatestDate.SelectedDate