EntityDAC

TCustomEntityContext.GetEntities<T> Method

The method is designed for retrieving an entity collection by specified criteria.

Class

TCustomEntityContext

Syntax

function GetEntities<T: TEntity>(LinqExpression: ILinqBase): IEntityEnumerable<T>; overload;

Type parameters
T
The class type of entities to be retrieved
Parameters
LinqExpression
A complete LINQ query for selecting entities.

Remarks

The method returns a collection of entities of the specified class type by the specified LINQ query.. Collection members created by this method are initially attached to the data context and placed to the object cache, therefore you can already perform modification operations for them: TCustomEntityContext.Delete, TCustomEntityContext.Save, TCustomEntityContext.Cancel without pre-calling TCustomEntityContext.Attach. In addition, these entity instances will be automatically destroyed, and there will be no need to provide for their manual destruction.

Example

Examples of calling the method:

var
  EmpType: IMetaType;
  Expression: ILinqQueryable;
EmpEntities: IEntityEnumerable<TEmp>;
begin
  EmpType := Context['Emp'];
  Expression := Context.From(EmpType).Where(EmpType['Deptno'] = 20).Select;
  EmpEntities := Context.GetEntities<TEmp>(Expression);
  // ...
end; 

See Also

© 1997-2017 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback