TechTalk Genome v4.2

ElementTypeAttribute Class

Specifies the element type of a member with return type of Set.

For a list of all members of this type, see ElementTypeAttribute Members.

System.Object
   Attribute
      ElementTypeAttribute

[AttributeUsage(ValidOn="Parameter, ReturnValue", AllowMultiple="False", Inherited="True")]
public class ElementTypeAttribute : Attribute

Remarks

The ElementTypeAttribute attribute specifies the element type of a member with return type of Set. The element type is used to determine the type of the candidate elements when the member is used in an OQL expression (e.g. filtering, sorting, projection). If the ElementTypeAttribute is not specified for a member that returns a Set, additional type-cast expressions has to be applied on the candidate element if the member result is used in OQL.

The attribute has to be defined on the return type of a property or a method.

Example


Employee.cs
                    
public abstract class Employee 
{
    public abstract int Id { get; set; }
    public abstract int Salary { get; set; }
    public abstract Employee Boss { get; set; }
    public abstract Set Workers
    {
        [return: ElementType(typeof(Employee))]
        get;
    }
    public abstract int AverageSalary { get; }
}               
                

NorthwindSchema.xml    
                    
<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
    <Type name="Employee">
        <Member name="Id"><PersistentField /></Member>
        <Member name="Salary"><PersistentField /></Member>
        <Member name="Boss"><NearObjectReference /></Member>
        <Member name="Workers"
            Oql="extentof(Employee)[e: e.Boss == this]" />
        <Member name="AverageSalary"
            Oql="Sql.Avg([Salary]Workers)" />
    </Type>
</Mapping>
                

Requirements

Namespace: TechTalk.Genome.Mapping

Assembly: TechTalk.Genome (in TechTalk.Genome.dll)

Version: 4.2.4.4

Editions: Professional, Evaluation, Express

Database Platforms: Microsoft SQL Server 2000, Microsoft SQL Server 2005, Orcale 9i Release 2, Oracle 10g Release 2

See Also

ElementTypeAttribute Members | TechTalk.Genome.Mapping Namespace | <Oql> Element | Projection | Filtering | Sorting