Kentico自定义表查询和/或组合

Kentico自定义表查询和/或组合,kentico,Kentico,我在肯蒂科10号有一张定制的桌子。有些记录的纬度和经度为空。我正在尝试排除这些行,同时在郊区、州、邮政编码上保留现有的where搜索。和/或的当前组合不起作用。有没有更好的建议 var locationsQuery = CustomTableItemProvider.GetItems("customtable.ProjectName_PostcodeSuburb") .WhereNotNull("Latitu

我在肯蒂科10号有一张定制的桌子。有些记录的纬度和经度为空。我正在尝试排除这些行,同时在郊区、州、邮政编码上保留现有的where搜索。和/或的当前组合不起作用。有没有更好的建议

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");

找到了解决方案,在文档中不太容易找到。需要创建where条件并将其作为查询中的where传递

var localityWhereCondition = new WhereCondition().WhereLike("Suburb", locationLike)
               .Or()
               .WhereLike("Postcode", locationLike)
               .Or()
               .WhereLike("State", locationLike)
               .Or()
               .WhereLike("Suburb + ', ' + State + ', ' + Postcode", locationLike);

var locationsQuery = CustomTableItemProvider.GetItems("customtable.ProjectName_PostcodeSuburb")
               .WhereNotNull("Latitude")
               .And()
               .WhereNotNull("Longitude")
               .And()
               .Where(localityWhereCondition)
               .Columns("Suburb, State, Postcode")
               .OrderBy("Suburb, State, Postcode")
               .TopN(20);

找到了解决方案,在文档中不太容易找到。需要创建where条件并将其作为查询中的where传递

var localityWhereCondition = new WhereCondition().WhereLike("Suburb", locationLike)
               .Or()
               .WhereLike("Postcode", locationLike)
               .Or()
               .WhereLike("State", locationLike)
               .Or()
               .WhereLike("Suburb + ', ' + State + ', ' + Postcode", locationLike);

var locationsQuery = CustomTableItemProvider.GetItems("customtable.ProjectName_PostcodeSuburb")
               .WhereNotNull("Latitude")
               .And()
               .WhereNotNull("Longitude")
               .And()
               .Where(localityWhereCondition)
               .Columns("Suburb, State, Postcode")
               .OrderBy("Suburb, State, Postcode")
               .TopN(20);

您可以在此处了解如何访问它的全部要点-

从同一页引用快照

WhereEquals("ColumnName", value) - checks the equality of the value in the specified column with the value specified in the second parameter.
WhereGreaterThan("ColumnName", value) - compares the value in the specified column with the second parameter.
WhereNull("ColumnName") - select only rows where the specified column has a NULL value.
WhereNot(whereCondition) - negates the specified where condition.
WhereStartsWith("ColumnName", "Value") - only works for text columns. Selects only rows whose value in the specified column starts with the given value.

您可以在此处了解如何访问它的全部要点-

从同一页引用快照

WhereEquals("ColumnName", value) - checks the equality of the value in the specified column with the value specified in the second parameter.
WhereGreaterThan("ColumnName", value) - compares the value in the specified column with the second parameter.
WhereNull("ColumnName") - select only rows where the specified column has a NULL value.
WhereNot(whereCondition) - negates the specified where condition.
WhereStartsWith("ColumnName", "Value") - only works for text columns. Selects only rows whose value in the specified column starts with the given value.

你好我可以请您通过以下方式提交有关文件的反馈吗?该链接可以在每个文档页面的底部找到。请告诉我们您在搜索过程中使用了哪些关键字,您最终在哪个页面上找到了解决方案,和/或您自己需要了解的具体部分。谢谢,我们真的很感激。嗨。我可以请您通过以下方式提交有关文件的反馈吗?该链接可以在每个文档页面的底部找到。请告诉我们您在搜索过程中使用了哪些关键字,您最终在哪个页面上找到了解决方案,和/或您自己需要了解的具体部分。谢谢,我们真的很感激。