不知道为什么我的查询将返回一个空 [英] dont get why my query is returning a null
本文介绍了不知道为什么我的查询将返回一个空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是有关当我想删除一个项目掀起了订单,
我只是不明白为什么它返回一个空值,它应该只是删除的项目。
保护无效gvRevOrder_RowDeleting(对象发件人,GridViewDeleteEventArgs E)
{
Int64的ID =新的Int64();
ID =(Int64的)e.Keys [产品ID];
使用(DatabaseCourseWorkEntities上下文=新DatabaseCourseWorkEntities())
{
CWInvoiceItem项目=(由对在context.CWInvoiceItems
其中,p.ProductID == ID
选择P).SingleOrDefault();
context.CWInvoiceItems.DeleteObject(项目);
context.SaveChanges();
}
下面我把事情我试图删除,正如你所看到的ProductID = 38和可变标识也有38任何想法的链接?
我已经试过各种如FirsOrDefault和这样的。
解决方案
- 检查
context.CWInvoiceItems
中包含任何数据 - 检查方面指向正确的数据源
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
这篇关于不知道为什么我的查询将返回一个空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文