2

我正在开发一个带有 SQLite 本地数据库的 Windows Phone 7 应用程序,我已经坚持了一点。

我定义了几个类,每个类都有一个映射设置,我希望检索一个带有一些过滤的列表。我发现了许多如何检查相等值的示例,但没有找到不相等检查的示例。

CSParameterCollection parameters = new CSParameterCollection();
        parameters.Add("@CurrentDate", currentDate);
        parameters.Add("@DirectionId", intVisszaut);
CSList<Trip> RouteTrips = Route.Trips.FilteredBy("Services.StartDate <= @CurrentDate and Services.EndDate >= @CurrentDate and Services." + DayOfWeek.ToString() + " = 1 and DirectionId = @DirectionId", parameters);

此过滤器可以正常工作,但是当我使用以下内容对其进行更新时,它会失败:

(Services.CalendarDates.Date != @CurrentDate 和 Services.CalendarDates.Date.ExceptionType != 2)

CSParameterCollection parameters = new CSParameterCollection();
        parameters.Add("@CurrentDate", currentDate);
        parameters.Add("@DirectionId", intVisszaut);
CSList<Trip> RouteTrips = Route.Trips.FilteredBy("(Services.CalendarDates.Date != @CurrentDate and Services.CalendarDates.Date.ExceptionType != 2) and Services.StartDate <= @CurrentDate and Services.EndDate >= @CurrentDate and Services." + DayOfWeek.ToString() + " = 1 and DirectionId = @DirectionId", parameters);

错误代码是:Vici.CoolStorage.WP7.dll 中出现“System.InvalidCastException”类型的第一次机会异常

Services 是 OneToOne,Services.CalendarDates 是 OneToMany 映射。我是否使用了太多过滤器值或我做错了什么?使用 <> 也不起作用。

4

2 回答 2

1

什么是Services.CalendarDates.Date.ExceptionType-您确定可以将其与像 2 这样的数字进行比较吗?

要调试这个:

  • 尝试删除过滤器表达式的每个部分,以确定导致失败的部分
  • 尝试链接到 CoolStorage 源代码 - 然后您可以确切地看到失败的原因(尽管这可能在他们的堆栈中很深,并且可能感觉有点不可读)
于 2012-03-04T14:14:11.320 回答
1

SQLite 不理解 != 语法。你应该使用<>

于 2012-03-05T19:38:43.467 回答