Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 实体数据源日期时间,其中参数_C#_Asp.net_Entity Framework - Fatal编程技术网

C# 实体数据源日期时间,其中参数

C# 实体数据源日期时间,其中参数,c#,asp.net,entity-framework,C#,Asp.net,Entity Framework,我有一个EDS,它查看带有日期时间的事件列表,我想要一个where参数,用于查看某一天的所有事件 我想要一个看起来像这样的: Where="it.EventStartDateTime = @testDate" 但是由于EventStartDateTime包含一个时间,而testDate只是一个日期,所以它们永远不会匹配 我试过了 Where="it.EventStartDateTime.Date = @testDate" 但是我得到一个关于Date不在模式中的错误(?) 我试过了 Where

我有一个EDS,它查看带有日期时间的事件列表,我想要一个where参数,用于查看某一天的所有事件

我想要一个看起来像这样的:

Where="it.EventStartDateTime = @testDate"
但是由于
EventStartDateTime
包含一个时间,而
testDate
只是一个日期,所以它们永远不会匹配

我试过了

Where="it.EventStartDateTime.Date = @testDate"
但是我得到一个关于
Date
不在模式中的错误(?)

我试过了

Where="it.EventStartDateTime Like @testDate"
这也不管用

有人知道怎么做吗


提前感谢

我们通过以下方式解决了这个问题:

        eventsEDS.Where = "it.EventStartDateTime >= @cDate && it.EventStartDateTime < @cDate1 "; 
        eventsEDS.WhereParameters.Add("cDate", TypeCode.DateTime, eventStartDateTime.ToShortDateString());
        eventsEDS.WhereParameters.Add("cDate1", TypeCode.DateTime, eventStartDateTime.AddDays(1).ToShortDateString());
eventsEDS.Where=“it.EventStartDateTime>=@cDate&&it.EventStartDateTime<@cDate1”;
eventsEDS.WhereParameters.Add(“cDate”,TypeCode.DateTime,eventStartDateTime.ToShortDateString());
eventsEDS.WhereParameters.Add(“cDate1”,TypeCode.DateTime,eventStartDateTime.AddDays(1.ToSortDateString());
虽然不理想,但效果很好