stimms
stimms

Reputation: 44054

Extract SQL from Subsonic 3

Is there a way to extract the SQL which is run against the database from a bit of subsonic? For instance I have

foreach (var item in EVT.All().Where(e => e.EVT_USRNAME == "stimms"))
        {
         ...
        }

Can I get at what is run?

Upvotes: 0

Views: 131

Answers (2)

MAbraham1
MAbraham1

Reputation: 1768

Simon, Another method that requires more under-hood revelation is to debug the Subsonic source-code. Set a breakpoint at your query, watch the evaluated statement, and look for the QueryText property.

MAbraham1

Upvotes: 0

Yogesh
Yogesh

Reputation: 14608

In Subsonic, you can get the command which will be executing against a query in this way:

IQueryable query = EVT.All().Where(e => e.EVT_USRNAME == "stimms");
SubSonic.Linq.Structure.DbQueryProvider provider = (SubSonic.Linq.Structure.DbQueryProvider)query.Provider;
string command = provider.GetCommand(query.Expression).CommandSql;

Upvotes: 1

Related Questions