Home

SQL generated by Linq doesn't include the parameter values (SQL tab)

edited January 2021

When running a linq query that contains parameters, the generated query doesn't show the parameter values used.

This Linq
var x = Guid.Parse("a34e9117-c95e-4b96-8fa0-0002016d915c");
var tasks = Tasks.IgnoreQueryFilters().Where(t=> t.Id == x).Select(t => t.Id).Dump();

Generates this SQL:
-- Region Parameters
-- @__x_0='?' (DbType = Guid)
-- EndRegion
SELECT [t].[Id]
FROM [Tasks] AS [t]
WHERE [t].[Id] = @__x_0
GO

Notice that the region parameter values are set to '?' and don't show the value used (not that the query would work anyway).

Some other details that may be important:

  • I've experienced this when connecting to EF Core contexts (using the dll) against both SQL and Postgres Dbs
  • SQL generated by Postgres Linq To Db connection not only has proper param values, but produces SQL that could be run without altering

Comments

Sign In or Register to comment.