TechTalk Genome v4.2

<View> Element

Defines a view on a type. Provides a named set of persistent properties and can be used for partial loading.

<Member name=" property1 "
View="(view|default)"
/>
<Member name=" property2 "
View="(view|default)"
/>
...

or

<Type name=" type ">
<View name="(view|default)" [ loadDerived="true|false" ] >
<Member>property1</Member>
<Member>property2</Member>
...
</View>
</Type>
type
A type specifying a persistent class.
property1, property2, ...
Presistent properties that are mapped using one of the field mappings.
view
A name identifying the view within the type.
loadDerived
If true, the view contains all the properties of the views defined on the derived types of type with the same view name. If false, the view does not contain the properties of the overriding views. If omitted, the loadDerived setting of the base view (the view defined on the base type of type) is used or true if the view has no base view.

Remarks

<View> element defines the view on the type, providing a named set of persistent propetries can be used for partial loading. The defined view contains:

When defining a view, the two definition syntaxes cannot be mixed. If a view is defined using the elment syntax, it cannot be extended with other properties using the attribute syntax. However, if a view is defined with the element syntax on a type, it can be overridden in a derived type using the attribute syntax and vica versa.

Genome defines built-in views as well:

Views can be used to parametrise the partial loading aspects of Genome .

Examples

          
BusinessContact.cs
                
public abstract class BusinessContact : Persistent {
    public abstract int Id { get; set }
    
    public abstract string FirstName { get; set; }
    public abstract string LastName { get; set; }
    public abstract string Position { get; set; }
    
    public abstract string CompanyName { get; set }
    public abstract string CompanyAddress { get; set }
    ...
}

public abstract class Supplier : BusinessContact {
    public abstract string RegistrationNumber { get; set; }
    public abstract string HomePage { get; set; }
    ...
}
                
          
NorthwindSchema.xml    
                
<Mapping xmlns="urn:TechTalk:TT.OODAL.XmlMapping">
    ...

    <Type name="BusinessContact">
        <RootInheritance />

        <!-- the "CompanyData" view will contain the properties "CompanyName", "CompanyAddress"
            and also "RegistrationNumber", "HomePage" declared on "Supplier" class -->
        <View name="CompanyData">
            <Member>CompanyName</Member>
            <Member>CompanyAddress</Member>
        </View>
        
        <!-- the "CompanyBaseData" view will contain the "CompanyName" property only -->
        <View name="CompanyBaseData" loadDerived="false">
            <Member>CompanyName</Member>
        </View>
        
        <!-- the default view of the "BusinessContact" will contain the properties
            "FirstName", "LastName", "CompanyName" -->
        <View name="default">
            <Member>FirstName</Member>
            <Member>LastName</Member>
            <Member>CompanyName</Member>
        </View>

        ...
        <!-- the "ContactPersonData" view will contain the properties 
            "FirstName", "LastName" and "Position" -->
        <Member name="FirstName" View="ContactPersonData"><PersistentField /></Member>
        <Member name="LastName" View="ContactPersonData"><PersistentField /></Member>
        <Member name="Position" View="ContactPersonData"><PersistentField /></Member>
        
        <Member name="CompanyName"><PersistentField /></Member>
        <Member name="CompanyAddress"><PersistentField /></Member>
    </Type>
                        
    <Type name="Supplier">
        <JoinedInheritance />
        
        <!-- the "CompanyData" view will contain the properties 
            "CompanyName", "CompanyAddress" declared on "BusinessContact" class
            and "RegistrationNumber", "HomePage" declared on "Supplier" class -->
        <View name="CompanyData">
            <Member>RegistrationNumber</Member>
            <Member>HomePage</Member>
        </View>
        
        <!-- the "CompanyData" view will contain the properties 
            "CompanyName" and "RegistrationNumber" -->
        <View name="CompanyBaseData">
            <Member>RegistrationNumber</Member>
        </View>

        ...
        <Member name="RegistrationNumber"><PersistentField /></Member>
        <Member name="HomePage"><PersistentField /></Member>
    </Type>
    
</Mapping>
                

Requirements

Type: TechTalk.Genome.Mapping.ViewXmlData

Assembly: TechTalk.Genome.dll

Version: 4.2.4

Editions: Professional, Evaluation

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

See Also

<LoadAlso> Element | DataRetrievalConfiguration.Add Overload List | PredictiveCacheManager.LoadWithView | PredictiveCacheManager.PrecacheWithView | Other Elements