无法创建类型>的常量值'System.Collections.Generic.List`1'

时间:2012-05-06 08:30:53

标签: c# asp.net linq filtering

我从ASP.NET中的queryextender调用以下方法。

该方法接受开始日期和结束日期,并过滤该日期范围的数据源。

public static IQueryable<TC_CUSTOMER_INFO> FilterByDate(IQueryable<TC_CUSTOMER_INFO> query, string fromDate, string toDate)
{
    DateTime _fromDate = DateTime.Parse("1000/01/01 00:00:00");
    DateTime _toDate = DateTime.Parse("9999/09/09 00:00:00");

    if (!String.IsNullOrEmpty(fromDate))
    {
        DateTime.TryParse(fromDate, out _fromDate);
    }
    if (!string.IsNullOrEmpty(toDate))
    {
        DateTime.TryParse(toDate, out _toDate);
    }
    return from e in query
           where e.ISSUED_DATE > _fromDate && e.ISSUED_DATE < _toDate 
           select e;
}

我尝试运行查询时收到的错误是:

  

无法创建类型的常量值   'System.Collections.Generic.List`1'。只有原始类型('如   在此上下文中支持Int32,String和Guid'。

我不知道为什么我收到这个错误。对我来说,这似乎是一个非常简单的查询。我错过了什么?

感谢。

0 个答案:

没有答案