2012-03-02 85 views
2

我正在使用SQLite本地數據庫在Windows Phone 7應用程序上工作,我堅持了一下。CoolStorage字段不等於過濾器

我有幾個類的定義,他們每個人都有一個映射設置,我希望檢索一些過濾列表。我發現了很多例子,如何檢查相等的值,但沒有檢查不相等的檢查。

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

服務是OneToOne,Services.CalendarDates是OneToMany映射。我是否使用了太多的過濾器值或者我做錯了什麼?它也不能使用<>。

回答

1

什麼是Services.CalendarDates.Date.ExceptionType - 您確定可以將其與數字比較爲2嗎?

要調試此:

  • 嘗試,以確定哪些部分刪除你的過濾器表達的每一部分引起的故障
  • 嘗試連接到CoolStorage源代碼 - 然後就可以看到到底是什麼失敗(雖然這可能是在它們的堆棧中相當深入,並且可能感覺有點不可讀)
+0

似乎表達式過濾器是錯誤的。我已經將它們全部刪除並逐個構建起來,並且以這種方式工作。 :P – Bhawk1990 2012-03-06 17:00:28

1

!=語法不被SQLite理解。您應該使用<>

+0

感謝您提供的信息,我之前沒有使用過SQLite,只是MySQL。 – Bhawk1990 2012-03-06 17:02:19