DataContext 的异常
我一直在互联网上进行一些搜索,但似乎找不到遮阳篷。 DataContext 可以抛出哪些异常?或者更具体地说,DataContext.SubmitChanges() 方法会抛出哪些异常?
编辑
作为参考,这里列出了 L2S DataContext 可能引发的已知异常:
- SqlException
- ChangeConflictException
- DuplicateKeyExceptionforeignKeyReferenceAlreadyHasValueException
- OutOfMemoryException
- (当未正确处置 DataContext 时)
I've been doing some searching on the internet, but I can't seem to find the awnser. What exceptions can a DataContext throw? Or to be more specific, what exceptions does the DataContext.SubmitChanges() method throw?
EDIT
For reference, here a List of possible known exceptions that could be thrown by the L2S DataContext:
- SqlException
- ChangeConflictException
- DuplicateKeyException
- ForeignKeyReferenceAlreadyHasValueException
- OutOfMemoryException (when not correctly disposing the DataContext)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你是对的,MSDN 在这里并没有多大帮助。这是我从头到尾记得的:
You're right, MSDN is not a great help here. This is what I can remember from the top of my head:
嗯,当错误发生在数据库级别时,存在底层数据库异常(我认为是 SqlClientException 类型)。当它检测到另一个用户的并发更改时,它会抛出 ChangeConflictException。可能还有其他方法取决于值是否为空(当它不应该为空时),诸如此类的事情。许多错误与上下文本身无关。
HTH。
Well, there are underlying database exceptions (I think of type SqlClientException) when the error occurs at the database level. There is the ChangeConflictException that it throws when it detects a concurrent change by another user. There may be others depending on whether a value is null when it shouldn't be, that sort of thing. A lot of the errors are unrelated to the context itself directly.
HTH.