我正在开发一个带有 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 映射。我是否使用了太多过滤器值或者我做错了什么?使用 <> 也不起作用。
最佳答案
什么是 Services.CalendarDates.Date.ExceptionType
- 您确定可以将其与 2 这样的数字进行比较吗?
要调试此:
- 尝试删除过滤表达式的每个部分,以确定导致失败的部分
- 尝试链接到 CoolStorage 源代码 - 然后您可以准确地看到失败的原因(尽管这可能在其堆栈的深处并且可能感觉有点难以阅读)
关于sqlite - CoolStorage 字段不等于过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9541092/