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


VulpesRank #55 · 29.2K reputationPosted Feb 3, 2012, 10:01 AM EST
That clause should be:
where n.recordedtime == dpLatestDate.SelectedDate
VulpesRank #55 · 29.2K reputationPosted Feb 3, 2012, 3:49 AM EST
where n.recordedtime = dpLatestDate.SelectedDate
C B22 reputationPosted Feb 3, 2012, 4:05 AM EST
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.
C B22 reputationPosted Feb 3, 2012, 10:12 AM EST
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
VulpesRank #55 · 29.2K reputationPosted Feb 3, 2012, 10:36 AM EST