-
First of all thanks for this library, it's very powerful and easy to use 👍 When I call LinQ Count() method on a SqlSet result, I get an exception "Connectionstring not initialized" :
It crashes on the ligne starting with "Tracing.Stop" and returns a System.InvalidOperationException. Here is the stack trace :
The error occurs in class Enumerator, method MoveNext() on the connection open: Any idea what's wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Are you sure the connection string is correct? |
Beta Was this translation helpful? Give feedback.
-
Yes it is correct: Server=DOM\SRVDB;Database=DDEF_DB;Trusted_Connection=True; During the call to System.Core.dll!System.Linq.Enumerable.Count(System.Collections.Generic.IEnumerable source), when the debugger enters Enumerator.MoveNext(), the command.Connection property is set, but the command.Connection.ConnectionString is empty... Before the call to System.Core.dll!System.Linq.Enumerable.Count(System.Collections.Generic.IEnumerable source), this property is correctly set. I don't know what happens in between and why the ConnectionString is empty. |
Beta Was this translation helpful? Give feedback.
-
You are disposing the connection by using |
Beta Was this translation helpful? Give feedback.
-
The query is deferred-executed, to query immediately use |
Beta Was this translation helpful? Give feedback.
-
Ah yes you are totally right! I read that in the documentation but totally forgot to take it into account. Thanks a lot for your kind help, and sorry about creating an issue regarding this, it was obviously my mistake. |
Beta Was this translation helpful? Give feedback.
-
No problem, if you have more questions just create an issue. |
Beta Was this translation helpful? Give feedback.
The query is deferred-executed, to query immediately use
ToList()
orToArray()
, then you don't have to worry about the connection going out of scope.