MightyOrm / Mighty

A new, small, dynamic micro-ORM. Highly compatible with Massive, but with many essential new features.
BSD 3-Clause "New" or "Revised" License
101 stars 20 forks source link

ConnectionTimeout not working #46

Closed starsoheil2007 closed 1 year ago

starsoheil2007 commented 1 year ago

Hi I have this line in my connection string

Connection Timeout=3000;

but I got this exception :

Timeout expired.

My query takes 30 seconds to get result in SQL server .

mikebeaton commented 1 year ago

That sets the connection timeout, not the command timeout.

You should use CreateCommand in Mighty. (There are lots of variants to fully set up any parameters, just as you would when normally letting Mighty create it's own commands internally.) Then, set the DbCommand.CommandTimeout property, then pass the command to Mighty's Query, Execute, Single, etc. (or the Aysnc versions) which all have a variant which takes a DbCommand.

Btw, when using the Mighty methods which accept a DbCommand, you are recommended to always pass in a command created by Mighty's CreateCommand, not one you created from scratch yourself (to get all the setup which Mighty does by default).