【问题标题】:CoolStorage field not equals filterCoolStorage 字段不等于过滤器
【发布时间】:2012-03-21 09:59:37
【问题描述】:

我正在开发一个带有 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 映射。我是否使用了太多过滤器值或我做错了什么?使用 也不起作用。

【问题讨论】:

    标签: sqlite windows-phone-7 coolstorage


    【解决方案1】:

    Services.CalendarDates.Date.ExceptionType 是什么 - 你确定它可以与像 2 这样的数字相比较吗?

    要调试这个:

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

    【讨论】:

    • 似乎表达式过滤器错误。我已经将它们全部删除并一个接一个地建立起来,它就是这样工作的。 :P
    【解决方案2】:

    SQLite 不理解 != 语法。你应该使用&lt;&gt;

    【讨论】:

    • 感谢您提供的信息,我之前没有使用过SQLite,只是使用了MySQL。
    猜你喜欢
    • 2023-03-25
    • 2014-05-05
    • 2014-08-07
    • 2016-05-06
    • 2022-01-23
    • 2015-12-20
    • 1970-01-01
    • 2015-01-12
    相关资源
    最近更新 更多