我正在使用System.Data.SQLite,我正在尝试检索由下面的查询表达式生成的 SQL 字符串。查询正确执行,但 SQL 字符串为SELECT NULL AS [EMPTY]
.
似乎GetCommand().CommandText
不支持,但如果支持,还有什么方法可以访问生成的 SQL 字符串?
[<Test>]
member this.showSQL() =
let connectionString = sprintf @"Data Source=%s;UTF8Encoding=True;Version=3" dbFilename
let connection = new SQLiteConnection(connectionString)
use dc = new DataContext(connection)
let channelMap = dc.GetTable<ChannelData>()
let map = query {
for row in channelMap do
where (row.ChannelId = 1)
select (row.ChannelId, row.Data0, row.State) }
let cmd = dc.GetCommand(map).CommandText;
printf "SQL: %s" cmd