更新时间:2023-02-21 21:15:04
您可以选择不发送StartDate。
You can choose not to send StartDate.
示例:
dynamic parameters = new {
};
if (!string.IsNullOrWhiteSpace(startDate))
{
parameters.StartDate = startDate;
}
connection.Query<MyObject>("[dbo].[sp_MyStoredProcedure]"), parameters, commandType: CommandType.StoredProcedure);
编辑:
此外,您存储的过程必须接受空值。这是一个例子:
Also, your stored procedure must accept nulls. Here's an example:
CREATE PROCEDURE [ExampleProc]
@StartDate datetime = null
AS
Select @StartDate