本文介绍了通过DataContext记录实际的SQL语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在忙于使用DataContext从数据库查询数据的相对较大的应用程序.当前,我们具有集中的错误处理和日志记录功能,但问题是,如果存在sql异常,则它不会记录实际的SQL查询.

是否有任何简单的方法可以在不使用我们每次使用DataContext的情况下都将其记录下来的情况下集中实现呢?
我们有一个从我们使用的DataContext继承的类.在将SQL语句通过此类传递到实际的DataContext时捕获它们是理想的选择,但是对于Linq来说这有点困难,因为它没有字符串SQL命令.

任何建议将不胜感激.

Hi All

I''m busy working on a relatively big application that is using a DataContext to query data from the database. We currently have central error handling and logging but the problem is that if there is a sql exception, it doesn''t log the actual SQL query.

Is there any easy way of implementing this centrally without logging it at each instance we use the DataContext?

We have a class that inherits from DataContext that we use. It would be ideal to catch the SQL statements as they pass through this class to the actual DataContext but it''s a bit difficult with Linq as there is no string SQL command.

Any suggestions would be greatly appreciated.

推荐答案



这篇关于通过DataContext记录实际的SQL语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 21:51