this keyword refers to the candidate element declared in any outer scope (the semantics of the this keyword are
not altered when an explicit alias is used).
If omitted, the this keyword can be used to refer to the candidate element of set.
This construct is used to retrieve a set of transient objects from the database. The expressions specified in the initializer can be scalar, persistent or nested array expressions.
The element type of the set projected with this construct is of the specified transient type that can be indexed on the client code that processes the elements of the set. Further projection, filtering or sorting operations are not supported on the projected set.
This projection operation supports two alternative syntax flavours:
The first one attempts to match the return types inferred from the expressions to a corresponding constructor
overload of the specified transient type.
The second one allows arbitrary public properties of the specified transient type to be initialised with the given expressions.
public class ExtendedEmployee
{
public Employee PersistentData;
public int NumberOfReports;
public ExtendedEmployee(Employee persistentData, int numberOfReports)
{
PersistentData = persistentData;
NumberOfReports = numberOfReports;
}
}
Set<ExtendedEmployee> employeeInfos = dd.Extent<Employee>().Select<ExtendedEmployee>("new ExtendedEmployee( this, Reports.Count )");
foreach (ExtendedEmployee e in employeeInfos)
{
Console.WriteLine("{0} {1}: {2} reports", e.FirstName, e.LastName, e.NumberOfReports);
}
Projection | OqlReference.Chapter5