TechTalk Genome v4.2

<QueryProvider> Element

Instructs Genome to generate an implementation for a type that contains entry point queries to the domain model.

<Type name=" type ">
<QueryProvider />
</Type>
type
A type specifying an interface or an abstract class.

Remarks

<QueryProvider> element instructs Genome to generate an implementation for a type that contains entry point queries to the domain model. The DataDomain.QueryProvider<S> can be used to create an instance of the query.

All members of the class need to be mapped in OQL because Genome implements only those. Leaving any members unmapped in OQL makes it impossible for Genome to provide an instance of the query provider during runtime; in fact, compilation of the query provider would already fail.

Please refer to the article OqlReference.Chapter21 for further information on how to use this feature.

Examples

Defining a query provider interface:

                    
public interface IAnimalQueries
{
    Set<Animal> Extent { get; };
    Set<Animal> NameFilter(string searchPattern);
    Set<Animal> AgeFilter(int minAge, int maxAge);
    Set<Animal> AgeFilter(int minAge);

    int GetAverageAge();
}
                    
                
Mapping the query provider interface:
                    
<Type name="IAnimalQueries">
    <QueryProvider />

    <Member name="Extent" >
        <Oql> <![CDATA[  extentof(Animal)  ]]> </Oql>
    </Member>

    <Member name="NameFilter" signature="System.String">
        <Oql> <![CDATA[  Extent[Name.IsLike(searchPattern)]  ]]> </Oql>
    </Member>

    <Member name="AgeFilter" signature="System.Int32,System.Int32">
        <Oql> <![CDATA[  Extent[Age > minAge && Age < maxAge]  ]]> </Oql>
    </Member>

    <Member name="AgeFilter" signature="System.Int32">
        <Oql> <![CDATA[  Extent[Age > minAge]  ]]> </Oql>
    </Member>

    <Member name="GetAverageAge" >
        <Oql> <![CDATA[  Sql.Avg([Age]Extent())  ]]> </Oql>
    </Member>
</Type>
                    
                

See Also

Other Elements | DataDomain.QueryProvider<S> | DataDomain.QueryProvider<S>