使用 ExecSQL 过滤日期时间
Filter DateTime with ExecSQL
我正在应用这个过滤器:
var date = new DateTime(2019, 06, 20).ToUniversalTime().ToString("dd/MM/yyyy HH:mm");
MAPITable mt = session.Stores.MAPITable;
mt.Item = inbox.Items;
var records = mt.ExecSQL($"select Subject, EntryID from Inbox Where \"urn:schemas:httpmail:datereceived\" > {date}");
我有这个例外:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ConsoleApplication1.exe
附加信息:不支持的运算符:/
应该可以做这种过滤吗? [使用 > 运算符]
您需要确保日期变量是 SQL 格式并用单引号编码。
我正在应用这个过滤器:
var date = new DateTime(2019, 06, 20).ToUniversalTime().ToString("dd/MM/yyyy HH:mm");
MAPITable mt = session.Stores.MAPITable;
mt.Item = inbox.Items;
var records = mt.ExecSQL($"select Subject, EntryID from Inbox Where \"urn:schemas:httpmail:datereceived\" > {date}");
我有这个例外:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ConsoleApplication1.exe
附加信息:不支持的运算符:/
应该可以做这种过滤吗? [使用 > 运算符]
您需要确保日期变量是 SQL 格式并用单引号编码。