Re:Linq-SQL规范可编辑datagridview示例代码 [英] Re: Linq-SQL canonical editable datagridview sample code

查看:59
本文介绍了Re:Linq-SQL规范可编辑datagridview示例代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Marc,

Marc,


>我不知道是否有更简单的方法,但 :$ b $怎么样b
>I don''t know if there is an easier way, but how about:



非常感谢。我有使用

正确实现添加行的问题。


用户在网格的最后一行按向下箭头开始添加新行。

然后用户改变主意,决定不添加新行,

按下箭头。

DataGridView不再显示此未完成的行。


但是实体仍然在DataContext中并且被添加到数据库上

SubmitChanges。

如何防止这个鬼实体的添加?


Andrus。

Thank you very much. I have issue on implementing add row properly using
this.

User presses down arrow in last row in grid starting adding new row.
Then user changes its mind desiding that new row should not added and
presses up arrow.
DataGridView does not show this unfinished row anymore.

However entity remains in DataContext and is added to database on
SubmitChanges.
How to prevent this ghost entity addition ?

Andrus.

推荐答案

可能你需要实施ICancelAddNew,但要看一眼,

BindingList< Talready这样做,正确调用RemoveItem ......

嗯......我会调查......
Probably you''d need to implement ICancelAddNew, but taking a peek,
BindingList<Talready does this, calling RemoveItem correctly...
hmmm... I''ll investigate...


I用LINQ-to-SQL看过这个,我无法重现

问题;如果我添加和删除一行(在立即和

延迟取消的任意组合中),则不会对数据库进行任何更改。


所以:是您使用LINQ-to-SQL,还是使用DbLinq?如果是后者,那么我怀疑它有问题。注意到这个微不足道的变化(琐碎的

意思是字面意义上的 - 不打算光顾)。


您可以编写列表来跟踪插入本身,但

这应该是数据上下文的工作。当然,如果这个

实际上是LINQ-to-SQL,请告诉我,我会重试...


Marc
I''ve looked at this with LINQ-to-SQL, and I cannot reproduce the
issue; if I add and remove a row (in any combination of immediate and
delayed cancel), then no change is applied to the database.

So: are you using LINQ-to-SQL, or are you using DbLinq? If the latter,
then I suspect it has "issues" noticing this trivial change (trivial
meant in the literal sense - not intended to be patronising).

You might be able to write the list to track insertions itself, but
this should be the job of the data-context. Of course, if this
actually is LINQ-to-SQL, please let me know and I''ll retry...

Marc


Marc,
Marc,

>可能你需要实施ICancelAddNew,但要看一眼,
BindingList< Talready这样做,正确调用RemoveItem ...
>Probably you''d need to implement ICancelAddNew, but taking a peek,
BindingList<Talready does this, calling RemoveItem correctly...



我观察到以下情况:


1.按下DataGridView最后一行中的箭头调用AddNewCore(),其中
将新实体添加到

DataContext。


2.按向上箭头doest * not *调用RemoveItem。因此添加假实体将保存在SubmitChanges()上。


我想知道Linq-SQL如何正确执行此操作,因为RemoveItem()不是

叫。


我正在使用DbLinq,但这不应该依赖于Linq提供商。


Andrus 。

I observed the following:

1. Pressing down arrow in last line of DataGridView calls AddNewCore() which
adds new entity to
DataContext.

2. Pressing Up Arrow doest *not* call RemoveItem. So added fake entity will
me saved on SubmitChanges().

I''m wondering how Linq-SQL performs this correctly since RemoveItem() is not
called.

I''m using DbLinq but this should not depend on Linq provider.

Andrus.


这篇关于Re:Linq-SQL规范可编辑datagridview示例代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆