开发者

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 开发者_JAVA百科get at what is run?


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;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜