【发布时间】:2014-03-17 23:58:48
【问题描述】:
这是我的代码:
IEnumerable<DataAccessLayer.SQLPendingEventRecord> dataset1 = _v3Context.SQLPendingEvents
.Where(sp => sp.EventType.ToString() == str100w && sp.EventDateTime > dtStartDate && !sp.KeyDeviceID.ToString().Contains('~'))
.AsEnumerable() // further processing occurs on client
.Select((sp, index) => new DataAccessLayer.SQLPendingEventRecord
{
ID = index + 1,
KeyDeviceID=sp.KeyDeviceID,
UpdateTime=sp.UpdateTime,
EventClass=sp.EventClass,
EventCode=sp.EventCode,
EventType=sp.EventType,
EventDateTime=Convert.ToDateTime(sp.EventDateTime),
KeyPropertyID=Convert.ToInt32 (sp.KeyPropertyID),
KeyEntityID=Convert.ToInt32 (sp.KeyEntityID),
EventText=sp.EventText,
KeyUserID=sp.KeyUserID,
//sp.EventImage,
TaskType=sp.TaskType,
TaskSubType=sp.TaskSubType,
UniqueTaskID=sp.UniqueTaskID
}).ToList();
我刚刚添加了:&& !sp.KeyDeviceID.ToString().Contains('~')) 现在,我收到奇怪的错误消息:“System.String”类型不支持序列运算符。 在此之前,我没有任何问题。 现在,我收到了这个神秘的错误信息。 由于数据库的大小,我需要将所有这些都放在一个查询中。 有什么想法吗?
【问题讨论】:
-
对于您正在使用的提供程序,
Contains()可能没有等效的 SQL。 -
KeyDeviceId的类型是什么? -
这一行工作正常: dataset1 = dataset1.Where(sp => !sp.KeyDeviceID.ToString().Contains('~')).ToList();
-
KeyDeviceId 是一个字符串。
-
那你为什么打电话给
ToString呢?