dont get why my query is returning a null
My problem is related to when I want to Delete a Item off a Order,
I just dont get why it is returning a null value it should just delete the item.
protected void gvRevOrder_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Int64 ID = new Int64();
ID = (Int64)e.Keys["ProductID"];
using (DatabaseCourseWorkEntities context = new DatabaseCourseWorkEntities())
{
CWInvoiceItem item = (from p in context.CWInvoiceItems
where p.ProductID == ID
开发者_运维技巧 select p).SingleOrDefault();
context.CWInvoiceItems.DeleteObject(item);
context.SaveChanges();
}
below i have put a link of the thing i am trying to delete and as you can see the ProductID = 38 and the Variable ID also has 38 any ideas?
I've tried all sorts such as FirsOrDefault and such.
- Check that
context.CWInvoiceItems
contains ANY data - Check that the context points to the correct data source
精彩评论