由DataContext的例外 [英] Exceptions by DataContext

查看:131
本文介绍了由DataContext的例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在做一些在互联网上搜索,但我似乎无法找到awnser。可一个DataContext抛出什么异常?或者更具体的,有什么异常是否DataContext.SubmitChanges()方法抛出?

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?

修改结果
仅供参考这里一个可能的已知的例外列表,可以由L2S的DataContext抛出:

EDIT
For reference, here a List of possible known exceptions that could be thrown by the L2S DataContext:


  • 的SQLException

  • ChangeConflictException

  • DuplicateKeyException

  • ForeignKeyReferenceAlreadyHasValueException

  • OutOfMemoryException异常时(没有正确处理DataContext的)

  • SqlException
  • ChangeConflictException
  • DuplicateKeyException
  • ForeignKeyReferenceAlreadyHasValueException
  • OutOfMemoryException (when not correctly disposing the DataContext)

推荐答案

您说得对,MSDN是不是在这里有很大的帮助。这是我可以从我的头顶记住:

You're right, MSDN is not a great help here. This is what I can remember from the top of my head:


  • 的SQLException(从ADO.NET层)

  • ChangeConflictException(L2S)

  • DuplicateKeyException(L2S)

  • 凡是cusomized覆盖(部分无效OnXXXEntity)可能会提高

  • SqlException (from the ADO.NET layer)
  • ChangeConflictException (L2S)
  • DuplicateKeyException (L2S)
  • Anything that cusomized overrides (partial void OnXXXEntity) may raise

这篇关于由DataContext的例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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