我在Kentico 10中有一個自定義表格。某些記錄的空白經度和緯度爲空。我試圖排除這些行,同時維持現有的郊區,州,郵政編碼搜索。 And/Or的當前組合不起作用。有沒有建議,更好的方法?Kentico自定義表格查詢和/或組合
var locationsQuery = CustomTableItemProvider.GetItems("customtable.ProjectName_PostcodeSuburb")
.WhereNotNull("Latitude")
.And()
.WhereNotNull("Longitude")
.And()
.WhereLike("Suburb", locationLike)
.Or()
.WhereLike("Postcode", locationLike)
.Or()
.WhereLike("State", locationLike)
.Or()
.WhereLike("Suburb + ', ' + State + ', ' + Postcode", locationLike)
.Columns("Suburb, State, Postcode")
.OrderBy("Suburb, State, Postcode")
.TopN(20);
我也嘗試過作爲參數,似乎工作,但擔心SQL注入和不知道如何通過SQL參數。
string whereSql = string.Format("Latitude IS NOT NULL AND Longitude IS NOT NULL AND (Suburb LIKE '{0}' OR Postcode LIKE '{0}' OR State LIKE '{0}')", locationLike);
var locationsQuery = CustomTableItemProvider.GetItems("customtable.ClearView_PostcodeSuburb", whereSql, "Suburb, State, Postcode", 20, "Suburb, State, Postcode");
嗨。請問您通過[反饋鏈接](https://docs.kentico.com/k10/custom-development/retrieving-database-data-using-objectquery-api#feedback-link)提交文檔反饋?鏈接可以在每個文檔頁面的底部找到。請告訴我們您在搜索過程中使用了哪些關鍵字,您最終在哪個頁面上找到了解決方案,以及/或者您需要自己弄清楚哪些部分。謝謝,我們非常感謝。 – rocky