Click or drag to resize

QueryBuilder Class

Query builder for model objects
Inheritance Hierarchy
SystemObject
  SanteDB.OrmLiteQueryBuilder

Namespace:  SanteDB.OrmLite
Assembly:  SanteDB.OrmLite (in SanteDB.OrmLite.dll) Version: 2.2.1
Syntax
public class QueryBuilder

The QueryBuilder type exposes the following members.

Constructors
  NameDescription
Public methodQueryBuilder
Represents model mapper
Top
Properties
  NameDescription
Public propertyProvider
Provider
Top
Methods
  NameDescription
Public methodStatic memberCreateParameterValue
Create a parameter value
Public methodCreateQueryTModel(ExpressionFuncTModel, Boolean, ColumnMapping)
Create a query
Public methodCreateQueryTModel(ExpressionFuncTModel, Boolean, ModelSortTModel, ColumnMapping)
Create a query
Public methodCreateQueryTModel(IEnumerableKeyValuePairString, Object, ModelSortTModel, ColumnMapping)
Create query
Public methodCreateQueryTModel(IEnumerableKeyValuePairString, Object, String, ModelSortTModel, ColumnMapping)
Create query
Public methodCreateQueryTModel(IEnumerableKeyValuePairString, Object, String, Boolean, ListTableMapping, ModelSortTModel, ColumnMapping)
Query query
Public methodCreateSqlPredicate
Create the actual SQL predicate
Public methodCreateWhereCondition
Create a where condition
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodConvertTReturn
The purpose of this method is to convert object me to TReturn. Why? Because if you have an instance of Act that actually needs to be a SubstanceAdministration we can't just cast so we have to copy.
(Defined by ExtensionMethods.)
Public Extension MethodGetInstanceOfTDomain
Gets an instance of TDomain from me
(Defined by ModelExtensions.)
Top
Remarks
Because the ORM used in the ADO persistence layer is very very lightweight, this query builder exists to parse LINQ or HTTP query parameters into complex queries which implement joins/CTE/etc. across tables. Stuff that the classes in the little data model can't possibly support via LINQ expression. To use this, simply pass a model based LINQ expression to the CreateQuery method. Examples are in the test project. Some reasons to use this: - The generated SQL will gather all table instances up the object hierarchy for you (one hit instead of multiple) - The queries it writes use efficient CTE tables - It can do intelligent join conditions - It uses Model LINQ expressions directly to SQL without the need to translate from Model LINQ to Domain LINQ queries - It lets us hack the query (via IQueryHack interface) to manually write code
Examples
QueryBuilder.CreateQuery<Patient>(o => o.DeterminerConcept.Mnemonic == "Instance")
Examples
WITH cte0 AS ( SELECT cd_tbl.cd_id FROM cd_vrsn_tbl AS cd_vrsn_tbl INNER JOIN cd_tbl AS cd_tbl ON (cd_tbl.cd_id = cd_vrsn_tbl.cd_id) WHERE (cd_vrsn_tbl.mnemonic = ? ) ) SELECT * FROM pat_tbl AS pat_tbl INNER JOIN psn_tbl AS psn_tbl ON (pat_tbl.ent_vrsn_id = psn_tbl.ent_vrsn_id) INNER JOIN ent_vrsn_tbl AS ent_vrsn_tbl ON (psn_tbl.ent_vrsn_id = ent_vrsn_tbl.ent_vrsn_id) INNER JOIN ent_tbl AS ent_tbl ON (ent_tbl.ent_id = ent_vrsn_tbl.ent_id) INNER JOIN cte0 ON (ent_tbl.dtr_cd_id = cte0.cd_id)
See Also