| Visual Basic (Usage) | |
|---|---|
| |
- T
| C# | |
|---|---|
// ... Other code | |
This class represents a storage independent query. The query is then compiled by the framework and executed on a class that implements the IStorage interface. When creating an ObjectQuery you may specify different conditions, simple joins and sort options.
ObjectQueries may be used in any part of your application, since they are storage independent. You should always check if you can use an ObjectQuery before switching to the SqlQuery. Perhaps you can move some of the joins directly to the storage (stored procedure or view) to avoid using SqlQuery.
OPath
OPath is a storage indepentend query language that is transformed to a storage dependent query at runtime.
The language understands various different types of statements right now. In a statement you must always
use the property names of the corresponding persistent object. All the OPath is translated to a
storage depentend query when "compiled" (at runtime).
The following statements are supported:
Condition
A condition is a property name, a comparer and a parameter. You can use inline parameter or tags ({0}, {1}, ...)
that are replaced by the parameter at runtime. Using tags is strongly recommended (for dynamic parameters)
to avoid injections.
Samples: "UserName = {0}", "Duration < {0}", "UserName = 'Test'", "Duration < 10", "UserName Like {0}"
Simple Joins
Simple joins allow you to join an related object and check some properties of that object. If the properties
fullfil the conditions the original object is loaded (obsolete!).
Samples: "Call[Duration < 10]" checks if one of the connected calls of the user is shorter then 10
minutes.
Sort Options
Sort Options allow to sort the result of the query. They consist in a keyword "SortBy", the name of the
property that is sorted by and the sort direction. Currently only one property is allowed in a sort option.
Samples: "SortBy UserName Asc", "SortBy UserName Desc"
Concats and brackets
You can concat each condition to another and brackets are also allowed in a OPath statement.
Samples: "UseName = {0} And Password = {1}", "(Duration < 10 And Name = {1}) Or Name = 'Test'"
Custom commands
OPath supports also custom commands. The commands must be understood by the storage to work. The storage
itself converts them to a command that is then executed on the storage. The storage gets a
OECommand object that contains the name
of the command and could also contain arguments. See SubString below, which contains 1 and 3 as arguments.
Samples: "Upper(UserName)" is converted by Oracle to "TO_UPPER({0})" the {0} Tag stands for the name of the
field. "SubString(UserName, 1, 3)" is converted to a command that is understood by the storage.
System.Object
Chili.Opf3.Query.ObjectQuery
Requirements
Namespace: Chili.Opf3.Query
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
Assembly: Chili.Opf3 (in Chili.Opf3.dll)