Hi so i'm using linq to sql through table mapping. Which works. But as I'm new to C# as well as WPF I seem to be incapable of finding a way to populate a datagrid with IQueryable. My Query looks like this.
var STL = new STDB.reportDB(Properties.Settings.Default.dataConnString);
DateTime startDate = new DateTime(2015,2,1);
IQueryable<STDB.salesInvLine> lastMonthInvoiced = from salesinv in STL.Sales_Inv_Lines
where (salesinv.Shipment_Date.Year == startDate.Year
&& salesinv.Shipment_Date.Month == startDate.Month)
select salesinv;
dataGrid01.ItemsSource = lastMonthInvoiced;
This gives me a NullReferenceException error. Which as i understand it doesn't help very much as far as errors go.
I've also tried switching IQueryable with datagrid01.ItemsSource but no dice. I've bumped into examples that utilise the using().to list(); but i cant seem to tailor those methods to my own tables probably because i don't fully understand them. I am able to access individual rows with
foreach (STDB.salesInvLine salesinv in lastMonthInvoiced)
{
string code = salesinv.Document_No_;
DateTime ddate = salesinv.Shipment_Date;
}
But even still I can't figure out how to get this into a Datagrid. If someone could point me in the right direction please that would be much appreciated. I don't wanna have to give up and go back to VB.