开发者

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?

dont get why my query is returning a null

I've tried all sorts such as FirsOrDefault and such.


  1. Check that context.CWInvoiceItems contains ANY data
  2. Check that the context points to the correct data source
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜