这是我的产品类别:
public class Product : XPLiteObject
{
public string productId {get;set;}
}我使用Gridview来控制数据。当我用productId =“id-5”删除一行时;
gridview1.deleteSelectedRows();然后添加带有productId =“id -5”的新行;(删除相同的id i)
最后,我说;
unitOfWork1.CommitChanges();和例外收到:找到了一把假钥匙!
发布于 2014-11-03 08:47:38
似乎没有从数据库中删除相应的记录。有三个可能的原因:
- Disable the Deferred Deletion feature at this class by setting the [DeferredDeletionAttribute.Enabled](https://documentation.devexpress.com/#XPO/DevExpressXpoDeferredDeletionAttribute_Enabledtopic) property to false;
- Make sure that objects you are adding are always have a unique value in the key property;
- Instead of creating a new object with the key that is already used, restore the deleted one: [How to restore deleted objects (records)](https://www.devexpress.com/Support/Center/Question/Details/A753)
- You can physically remove from the database records being marked deleted. Use the [Session.PurgeDeletedRecords](https://documentation.devexpress.com/#XPO/DevExpressXpoSession_PurgeDeletedObjectstopic) method for this purpose.
https://stackoverflow.com/questions/26672931
复制相似问题