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
Post a Comment