【发布时间】:2017-09-01 02:00:24
【问题描述】:
我在 Kentico 10 中有一个自定义表。一些记录的纬度和经度为空。我试图排除这些行,同时保持对郊区、州、邮政编码的现有搜索。 And / Or 的当前组合不起作用。有没有建议的,更好的方法?
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");
【问题讨论】:
标签: kentico