我有一个Entity SQL查询:
SELECT VALUE t FROM MyEntities AS t WHERE t.Name = @p OR (@p IS NULL AND t.Name IS NULL)
我可以执行如下查询:
var results = context.CreateQuery<WorkflowInstance>( query,new ObjectParameter("p",name)).ToList();
但是,如果’name’变量为null,那么我得到System.ArgumentNullException.所以如果名称为null,我也尝试使用DBNull.Value,我得到以下异常:
System.ArgumentOutOfRangeException was caught
Message=The specified
parameter type ‘System.DBNull’ is not
valid. Only scalar types,such as
System.Int32,System.Decimal,
System.DateTime,and System.Guid,are
supported.