Class ObjectQueryBase<TQuery, TObject>
- Namespace
- CMS.DataEngine
- Assembly
- CMS.DataEngine.dll
Predefined query returning given object type. Uses the .generalselect query internally.
public abstract class ObjectQueryBase<TQuery, TObject> : DataQueryBase<TQuery>, ICMSQueryable<TObject>, ICMSQueryable, IObjectQuery<TQuery, TObject>, IDataQuery<TQuery>, IDataQuerySettings<TQuery>, IWhereCondition<TQuery>, IQueryParameters<TQuery>, IObjectQuery, IDataQuery, IDataQuerySettings, IWhereCondition, IQueryParameters, IQueryObjectWithValue, IQueryObject where TQuery : ObjectQueryBase<TQuery, TObject>, new() where TObject : BaseInfo
Type Parameters
TQueryTObject
- Inheritance
-
objectQueryParametersBase<TQuery>WhereConditionBase<TQuery>DataQuerySettingsBase<TQuery>DataQueryBase<TQuery>ObjectQueryBase<TQuery, TObject>
- Implements
-
ICMSQueryable<TObject>IObjectQuery<TQuery, TObject>IDataQuery<TQuery>IDataQuerySettings<TQuery>IWhereCondition<TQuery>IQueryParameters<TQuery>
- Derived
-
ObjectQuery<TObject>
- Inherited Members
- Extension Methods
Constructors
ObjectQueryBase(string)
Constructor
protected ObjectQueryBase(string objectType)
Parameters
objectTypestringObject type
Properties
ElementType
Returns the element type.
public Type ElementType { get; }
Property Value
- Type
Expression
Query expression
public Expression Expression { get; }
Property Value
- Expression
IsOffline
Returns true if the given collection is offline (disconnected from the database)
public bool IsOffline { get; }
Property Value
- bool
Name
Object name, empty by default
public override string Name { get; }
Property Value
- string
Object
Object instance of the specified type.
protected BaseInfo Object { get; set; }
Property Value
ObjectType
Returns the object type of the objects stored within the collection.
public virtual string ObjectType { get; set; }
Property Value
- string
Provider
Query provider
public IQueryProvider Provider { get; }
Property Value
- IQueryProvider
TypeInfo
Type info of the specified type
public ObjectTypeInfo TypeInfo { get; }
Property Value
TypedResult
Gets InfoDataSet<TInfo> representing the result of this query.
public virtual InfoDataSet<TObject> TypedResult { get; }
Property Value
- InfoDataSet<TObject>
UseObjectTypeCondition
If true, the query uses the object type condition.
public virtual bool UseObjectTypeCondition { get; set; }
Property Value
- bool
Methods
AsNested()
Creates a nested query from the given query
public virtual ObjectQuery<TObject> AsNested()
Returns
- ObjectQuery<TObject>
CopyPropertiesTo(IQueryObject)
Creates the clone of the collection.
public override void CopyPropertiesTo(IQueryObject target)
Parameters
targetIQueryObjectTarget class
CreateChild(IDataQuerySettings)
Creates the child collection based on the given provider
public ICMSQueryable<TObject> CreateChild(IDataQuerySettings settings)
Parameters
settingsIDataQuerySettingsQuery parameters
Returns
- ICMSQueryable<TObject>
ForEachObject(Action<TObject>, int)
Executes the given action for each item (TObject) in the result. Processes the items in batches of the given size.
public virtual void ForEachObject(Action<TObject> objAction, int batchSize = -1)
Parameters
objActionAction<TObject>Object action
batchSizeintBatch size. 0 means no batch processing. By default uses current paging settings.
GetClassName()
Gets the class name for current query
protected override string GetClassName()
Returns
- string
GetClassStructureInfo()
Gets the class structure info for this query
protected override ClassStructureInfo GetClassStructureInfo()
Returns
GetData()
Gets data set returned by object query or custom data set. Data set can be modified by calling ObjectEvents.GetData event.
protected override DataSet GetData()
Returns
- DataSet
GetDataSourceName()
Gets the unique query source ID
protected override string GetDataSourceName()
Returns
- string
GetDefaultOrderBy()
Gets the default order by columns
protected override string GetDefaultOrderBy()
Returns
- string
GetEnumerableTypedResult(CommandBehavior, bool)
Gets enumerable collection of TObject representing the result of this query.
public virtual IEnumerable<TObject> GetEnumerableTypedResult(CommandBehavior commandBehavior = CommandBehavior.Default, bool newConnection = false)
Parameters
commandBehaviorCommandBehaviorCommand behavior for the underlying reader.
newConnectionboolIf true, the underlying reader will be executed using its own dedicated connection.
Returns
- IEnumerable<TObject>
Returns the enumeration resulting from query execution.
Exceptions
- NotSupportedException
Thrown when the query does not support reader.
GetEnumerableTypedResultAsync(CommandBehavior, bool, CancellationToken?)
Asynchronously gets enumerable collection of TObject representing the result of this query.
public virtual Task<IEnumerable<TObject>> GetEnumerableTypedResultAsync(CommandBehavior commandBehavior = CommandBehavior.Default, bool newConnection = false, CancellationToken? cancellationToken = null)
Parameters
commandBehaviorCommandBehaviorCommand behavior for the underlying reader.
newConnectionboolIf true, the underlying reader will be executed using its own dedicated connection.
cancellationTokenCancellationToken?The cancellation instruction.
Returns
- Task<IEnumerable<TObject>>
Returns a task returning the enumeration resulting from query execution.
Exceptions
- NotSupportedException
Thrown when the query does not support reader.
GetEnumerator()
Returns an enumerator that iterates through the query results.
public virtual IEnumerator<TObject> GetEnumerator()
Returns
- IEnumerator<TObject>
GetExecutingQuery(DataQuerySettings)
Gets the query to execute against database
public override IDataQuery GetExecutingQuery(DataQuerySettings settings = null)
Parameters
settingsDataQuerySettingsParameters for the query
Returns
GetIDColumn()
Gets the ID column for this query
protected override string GetIDColumn()
Returns
- string
GetResults(IDataQuery, ref int)
Gets results from executing query
protected override DataSet GetResults(IDataQuery query, ref int totalRecords)
Parameters
queryIDataQueryExecuting query
totalRecordsintReturns the total records number
Returns
- DataSet
InitFromType<T>()
Initializes the query from the given type
protected void InitFromType<T>() where T : BaseInfo
Type Parameters
T
InitIDQuery(string)
Initializes the ID query
protected void InitIDQuery(string resultColumn)
Parameters
resultColumnstringResulting column
InitTypedResult(InfoDataSet<TObject>)
Initializes the typed result
protected virtual void InitTypedResult(InfoDataSet<TObject> typedResult)
Parameters
typedResultInfoDataSet<TObject>Result
NewEmptyQuery()
Creates a new empty query
protected override TQuery NewEmptyQuery()
Returns
- TQuery
ToString(bool)
Returns the string representation of the expression, with possibility of expanding parameters
public override string ToString(bool expand)
Parameters
expandboolIf true, the result is expanded with parameters so it can act as standalone value.
Returns
- string
TypeUpdated()
Updates the query class name based on the current status
protected virtual void TypeUpdated()
WithCodeName(string)
Sets the where condition for a specific object code name
public virtual TQuery WithCodeName(string codeName)
Parameters
codeNamestringCode name
Returns
- TQuery
WithGuid(Guid)
Sets the where condition for a specific object GUID
public virtual TQuery WithGuid(Guid guid)
Parameters
guidGuidObject GUID
Returns
- TQuery
WithID(int)
Sets the where condition for a specific object ID
public virtual TQuery WithID(int objectId)
Parameters
objectIdintObject ID
Returns
- TQuery
WithObjectType(string)
Changes the query to use the given object type. Applies the object type condition to the query. The new object type must have the same class name as the original one.
public virtual TQuery WithObjectType(string objectType)
Parameters
objectTypestringObject type for the query
Returns
- TQuery
WithSource(params TObject[])
Sets the given DataSet as the source of the data query
[Obsolete("Method was not intended for public use and will be removed.")]
public virtual TQuery WithSource(params TObject[] items)
Parameters
itemsTObject[]Source items
Returns
- TQuery
Operators
explicit operator InfoDataSet<TObject>(ObjectQueryBase<TQuery, TObject>)
Implicit operator for conversion from DataQuery class to DataSet
public static explicit operator InfoDataSet<TObject>(ObjectQueryBase<TQuery, TObject> query)
Parameters
queryObjectQueryBase<TQuery, TObject>Query object
Returns
- InfoDataSet<TObject>