c# - how to display full SQL query run by entity framework LINQ to SQL -


say have linq query:

var query = (from person in ctx.people person.name == "john" select person); 

ctx context inheriting system.data.entity.dbcontext.

now how full sql query including parameters? have tried:

var sql = ((objectquery) query).totracestring(); sql = query.string(); context.database.log = (s) => sql += s; 

the first solution throws invalid cast exception. second solution gives me query part references variables not included. third prints "variables" in strange format.

var query = person in ctx.people person.name == "john" select person; string sql = ctx.getcommand(query).commandtext;


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -