KB Article A59
Visible to All Users

How to construct complex queries

Description:
Is there more information available on how to construct complex queries?
For example when I have 3 entities (A,B,C) with associations: [A] 1---->n [B] m<----1 [C]
How do I efficiently query all [A] entities which have a relation with [C]?

Answer:
Please review the How to Compose Complex Criteria help topic. It describes how to create complex queries.
As for your particular task, you can use the following code:

C#
public class Task : XPObject { [Association("TaskAssignmentsTask", typeof(TaskAssignment))] public XPCollection TaskAssignments { get{ return GetCollection("TaskAssignments"); } } } public class TaskAssignment : XPObject { [Association("TaskAssignmentsTask")] public Task Task; [Association("TaskAssignmentsPerson")] public Person Person; } public class Person : XPObject { [Association("TaskAssignmentsPerson", typeof(TaskAssignment))] public XPCollection TaskAssignments { get { return GetCollection("TaskAssignments"); } } } new XPCollection(typeof(Task), new ContainsOperator("TaskAssignments", new GroupOperator( new BinaryOperator("Person", myPerson), new BinaryOperator( new OperandProperty("Task"), new OperandProperty("^.Oid"), BinaryOperatorType.Equal ) ) ) )

See also:
What criteria should I use to get objects for a collection property which is empty?
How to set query criteria for a collection which is a collection property of a persistent object
How to filter a collection by an associated objects' properties

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.