4

Is there a simple way to log all linq queries executed in an application?

I am currently using code first entity framework with a DbContext instead of the older DataBaseContext.I know for a fact that the DataBaseContext class has a Log property, but i do not know if there is something like the log property for the DbContext.

3

1 Answer 1

1

You can use .ToString() on IQueryable queries that you'll create. It will return SQL statement that will be executed on DB.
Then if you're using Repository pattern you can implement your logging logic without using any third-party libs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.