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 - CUDA code not processing if block properly -

Android Capture Image From Camera -

What is the `file` URI scheme in Puppet? -