Object Query

Matthew Lee asked on December 25, 2014 16:11

I am using Kentico 8.1 and try to join two class tables as below:

SELECT * 
FROM ClassTableA
LEFT JOIN ClassTableB ON ClassTableA.Col1 LIKE ClassTableB.Col1 + '%'
  1. If I construct this query using Object Query, how can I handle the like condition.

  2. If I create a custom view for this join tables, can I use object query to query this custom view?

Correct Answer

Brenden Kehren answered on December 29, 2014 13:44

Matthew,

Have you checked out the DataQuery post by Martin Hejtmanek? In there you can see some different WHERE conditions, the ones you might use are

  • WhereLike
  • WhereContains
  • WhereStartsWith
  • WhereEndsWith

Here is another post about Joins. I'd highly suggest against creating your own SQL view as you never know what might happen with an upgrade. If you had to write your own query, do so in the UI, you'd be suprized what you can do in there.

2 votesVote for this answer Unmark Correct answer

Recent Answers


Joshua Adams answered on December 26, 2014 17:57

Have you looked at the built in class binding? This would probably simplify things for unless there is a requirement which means you have to use a custom query.

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on December 27, 2014 04:53

  1. When saying handle, do you mean dynamically change? I'm not sure Kentico provides you with this possibility.
  2. When implementing query (for document type, custom table, custom class) you may query any table or view within Kentico database.
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.