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: 3.0.2081-alpha+d0a78774d3f97b9193d2ae2fef6d129ea9f29519
Syntax
public class QueryBuilder

The QueryBuilder type exposes the following members.

Constructors
 NameDescription
Public methodQueryBuilder Represents model mapper
Top
Properties
 NameDescription
Public propertyStatementFactory Provider
Top
Methods
 NameDescription
Public methodStatic memberAddQueryHacks Add query builder hacks
Public methodStatic memberCreateParameterValue Create parameter value
Public methodCreateQuery(Type, IDictionaryString, String, ColumnMapping) Create query
Public methodCreateQuery(Type, LambdaExpression, ColumnMapping) Create a query from expression without needing type
Public methodCreateQuery(Type, IDictionaryString, String, String, Boolean, IEnumerableTableMapping, ColumnMapping) Query query
Public methodCreateQueryTModel(ExpressionFuncTModel, Boolean, ColumnMapping) Create a query
Public methodCreateSqlPredicate Create the actual SQL predicate
Public methodCreateWhereTModel Create a query
Public methodCreateWhereCondition Create a where condition
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodToStringReturns 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 MethodWithControl With control parameter is used as a wrapper for _ parameters
(Defined by QueryFilterExtensions)
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
Example
QueryBuilder.CreateQuery<Patient>(o => o.DeterminerConcept.Mnemonic == "Instance")
See Also