Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

 

Performs relational database queries on domain database.

...

Relational database queries uses special markup to specify query to execute. Query structure is similar to SQL Select command but you may use sub queries and join clauses automatically handled.

Query Structure

<Query<Query

Start="0"
Start index of results to fetch. If not specified 0 value is used.

MaxLength="-1">
Maximum number of results to fetch. If not specified -1 (maximum results) is used.

<Parameters>
Query parameters.

<TargetSchema>MySchema</TargetSchema>
Name of schema of query target. Required.

<TargetTable>MyTable</TargetTable>
Name of table of query target. Required.

</Parameters>

<Columns>
List of columns to include in results.

<Column
 
Column The column definition. Any number of column can be specified.

Name="MyColumn"
Name of column or relation path. Please see Column Name for more information. Required.

Formula="None">
Aggregation formula like count, max etc.  If not specified no aggregation is applied. Please see Aggregation Formula for more information. 

<Properties>
Column specific properties. Currently  

...

<Column></Column>

</Columns>

<Where

Condition="And">

<Criteria>

...

>
Query criteria and block list. Criteria can be consist of criteria definitions or block definitions to group criteria for logical conditions (and / or).

<Criteria>
List of criteria values. 

<Criteria
The criteria definition. Any number of criteria can be specified. 

Name="MyColumn"
Column name or relation path to criteria to apply. Required.

Comparison="Equals"
Comparison method of criteria like equals or greater etc. If not specified Equals value is used. Please see Comparison for more information. 

Condition="And"
Condition of criteria to merge with previous criteria in list. "And", "Or" values are valid. If not used "And" value is used.

Formula="None">

<Value></Value>

                        <Properties>

<IgnoreIfEquals>MyValue</IgnoreIfEquals>

                        </Properties>

</Criteria>

<Criteria> ............ </Criteria>

</Criteria>

<Blocks>

<Block Condition="And">

<Criteria>

...

Aggregation formula like count, max etc. If not specified no aggregation is applied. Please see Formula for more information. 

<Value></Value>
Value of criteria. Value can be specified in static value or template format like "{{Code}}" or "000-{{Code}}-1111" to dynamically evaluate.
If not specified value used as empty string.
You can use "NULL" string value to specify null value.

<Properties>
Criteria specific custom properties. Currently IgnoreIfEquals only used.

<IgnoreIfEquals></IgnoreIfEquals>
 Specify to ignore this criteria if evaluated value is equals to value. In some cases you may want to remove criteria for specific values. For example; if user leaves filter value empty you may want to list all rows, not equal to '' (empty string)

</Properties>

</Criteria>

<Criteria> ............ </

...

Criteria>

</

...

Criteria>

...

<

...

</Blocks>

</Where>

<Order/>

<SubQueries>

<Query Name="">

</Query>

</SubQueries>

</Query>

 

 

 

 

This control allows you to query your emakin based relational databases and map them with your form data.

Here are samples;

Simple sample 1:

<Query Name="" Start="0" MaxLength="-1">
           <Parameters>
                   <TargetSchema Type="System.String, mscorlib"><![CDATA[Masraf]]></TargetSchema>
                   <TargetTable Type="System.String, mscorlib"><![CDATA[MasrafTipiGrubu]]></TargetTable>
          </Parameters>
             <Columns>
                    <Column Name="Kod" Formula="None">
               </Column>
                    <Column Name="Text" Formula="None">
               </Column>
            </Columns>
   <Where Condition="And"/>
        <Order>
                 <Order Name="Text" Type="Ascending"/> 
 </Order>
     <SubQueries/>
</Query>

 

Simple sample 2:

<Query Name="" Start="0" MaxLength="-1">
     <Parameters>
                  <TargetSchema Type="System.String, mscorlib"><![CDATA[Masraf]]></TargetSchema>
                  <TargetTable Type="System.String, mscorlib"><![CDATA[MasrafTipi]]></TargetTable>
     </Parameters>
           <Columns>
                 <Column Name="Kod" Formula="None">
                 </Column>
              <Column Name="Text" Formula="None">
              </Column>
        </Columns>
<Where Condition="And">
       <Criteria>
             <Criteria Name="GrupKodu" Comparison="Equals" Condition="And" Formula="None">
                 <Value Type="System.String, mscorlib"><![CDATA[{{MasrafTipiGrubu}}]]></Value>
             </Criteria>
       </Criteria>
</Where>
      <Order>
           <Order Name="Text" Type="Ascending"/></Order>
       <SubQueries/>
</Query>

 

Advance sample:

<Query Name="" Start="0" MaxLength="-1">

    <Parameters>

        <TargetSchema Type="System.String, mscorlib"><![CDATA[HR]]></TargetSchema>

        <TargetTable Type="System.String, mscorlib"><![CDATA[Ucretler]]></TargetTable>

    </Parameters>

    <Columns>

        <Column Name="Person.Id">

            <Properties>

                <XPath Type="System.String, mscorlib"><![CDATA[Person/PersonId]]></XPath>

            </Properties>

        </Column>

        <Column Name="Person.DisplayName">

            <Properties>

                <Caption Type="System.String, mscorlib"><![CDATA[Ad Soyad]]></Caption>

                <XPath Type="System.String, mscorlib"><![CDATA[Person/AdSoyad]]></XPath>

            </Properties>

        </Column>

        <Column Name="Durum.Tip">

            <Properties>

                <XPath Type="System.String, mscorlib"><![CDATA[Durum/Tip]]></XPath>

            </Properties>

        </Column>

        <Column Name="Durum.Ad">

            <Properties>

                <XPath Type="System.String, mscorlib"><![CDATA[Durum/Ad]]></XPath>

            </Properties>

        </Column>

        <Column Name="ProjePersonel.HizmetTipi.AltProje.Proje.Bolge">

            <Properties>

                <Caption Type="System.String, mscorlib"><![CDATA[Bölge]]></Caption>

            </Properties>

        </Column>

        <Column Name="ProjePersonel.HizmetTipi.AltProje.Proje.Ad">

            <Properties>

                <Caption Type="System.String, mscorlib"><![CDATA[Proje]]></Caption>

                <XPath Type="System.String, mscorlib"><![CDATA[Person/Proje]]></XPath>

            </Properties>

        </Column>

        <Column Name="ProjePersonel.HizmetTipi.AltProje.Ad">

            <Properties>

                <Caption Type="System.String, mscorlib"><![CDATA[Alt Proje]]></Caption>

                <XPath Type="System.String, mscorlib"><![CDATA[Person/AltProje]]></XPath>

            </Properties>

        </Column>

        <Column Name="ProjePersonel.HizmetTipi.Ad">

            <Properties>

                <Caption Type="System.String, mscorlib"><![CDATA[Hizmet Tipi]]></Caption>

                <XPath Type="System.String, mscorlib"><![CDATA[Person/HizmetTipi]]></XPath>

            </Properties>

        </Column>

        <Column Name="Employee.Organization.Code">

            <Properties>

                <XPath Type="System.String, mscorlib"><![CDATA[Person/SirketKod]]></XPath>

            </Properties>

        </Column>

    </Columns>

    <Where Condition="And">

        <Blocks>

            <Block Condition="And">

                <Criteria>

                    <Criteria Name="Parent.Durum" Comparison="Equals" Condition="Or">

                        <Value Type="System.String, mscorlib"><![CDATA[2]]></Value>

                    </Criteria>

                    <Criteria Name="Parent.Durum" Comparison="Equals" Condition="Or">

                        <Value Type="System.String, mscorlib"><![CDATA[]]></Value>

                    </Criteria>

                </Criteria>

            </Block>

            <Block Condition="And">

                <Criteria>

                    <Criteria Name="Durum" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[1]]></Value>

                    </Criteria>

                    <Criteria Name="Brut" Comparison="GreaterThanOrEqualTo" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{Ucret/UcretKucuk}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[0]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="Brut" Comparison="LessThanOrEqualTo" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{Ucret/UcretBuyuk}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[99999]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="OdemeTipi" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{OdemeTipi}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="HesaplamaTipi" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{HesaplamaTipi}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="Employee.Positions.OrganizationUnitPosition.Position.Id" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{Pozisyon}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="ProjePersonel.HizmetTipi.AltProje.Proje.Sirket" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{Sirket/Kod}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="ProjePersonel.HizmetTipi.AltProje.Proje.Id" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{Proje/Id}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="ProjePersonel.HizmetTipi.AltProje.Id" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{AltProje/Id}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="ProjePersonel.HizmetTipi.Id" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{HizmetTipi/Id}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                    <Criteria Name="Employee.RegistryNumber" Comparison="Equals" Condition="And">

                        <Value Type="System.String, mscorlib"><![CDATA[{{SicilNo}}]]></Value>

                        <Properties>

                            <IgnoreIfEquals Type="System.String, mscorlib"><![CDATA[]]></IgnoreIfEquals>

                        </Properties>

                    </Criteria>

                </Criteria>

            </Block>

        </Blocks>

    </Where>

    <Order>

        <Order Name="Person.DisplayName" Type="Ascending"/></Order>

    <SubQueries/>

Blocks>
List of blocks to group criteria. 

<Block
The block definition. 

Condition="And">
Condition to merge with previous blocks. If not specified And value is used.

<Criteria>
List of criteria. Same with above criteria definition. 

<Criteria> ............ </Criteria>

</Criteria>

</Block>

</Blocks>

</Where>

<Order>
List of ordering columns. 

<Order
The order definition. 

Name="MyColumn"
Column name or relation path to apply order. Required. 

Type="Ascending"/>
Type of ordering. "Ascending", "Descending" values are valid. If not specified "Ascending" value is used.

</Order>

<SubQueries>
List of subqueries to return as related child rows. 

<Query
Subquery definition. Same with above only Name attribute is required.

Name="">
Name of table relation to get rows as child.

</Query>

</SubQueries>

</Query>

Formula

Formula specifies the method of evaluation of row values. Formula enumeration can be one of following values;

ValueDescription
NoneNo aggregation is applied. All values in rows.
CountCount of row values.
CountDistinctCount of distinct values in rows.
SumSum of row values. Valid for numeric type columns.
SumDistinctSum of distinct values in rows. Valid for numeric type columns.
AvgAverage of row values. Valid for numeric type columns.
AvgDistinctAverage of distinct values in rows. Valid for numeric type columns.
MinMinimum value in rows.
MaxMaximum value in row values.

Comparison

Specifies the comparison method of criteria value.

ValueDescription
EqualsAll rows with same value.
LessThanAll rows that less than criteria value.
LessThanOrEqualToAll rows that less or equals to criteria value.
GreaterThanAll rows that greater than criteria value.
GreaterThanOrEqualToAll rows that greater or equals to criteria value.
DifferentAll rows with different than criteria value.
LikeAll rows that likes to criteria value. Criteria value can be used with * (star character) Like *ABC, ABC*, *ABC*

 

Column Name

Column names can be specified as directly column name or relation path. Relation paths can be specified as "Relation.Relation.Column" format.

Image Added

 For example you can use following values as column name.

Column NameDescription
NameName of customer
Orders.IdId of order
Orders.Product.NameName of ordered product

Example Query

Following query returns the all customer name and count of orders by product name criteria. Each row also contains the list of related customer orders as a child rows.

Code Block
<Query>
	<Parameters>
    	<TargetSchema>Customer</TargetSchema>
		<TargetTable>MySchema</TargetTable>
	</Parameters>
	<Columns>
		<Column Name="Name" Formula="None" />
		<Column Name="Orders.Id" Formula="Count" />
	</Columns>
	<Where>
		<Criteria>
			<Criteria Name="Orders.Product.Name" Comparison="Like">
				<Value>{{ProductName}}</Value>
			</Criteria>
		</Criteria>
	</Where>
    <Order>
		<Order Name="Orders.Product.Name" Type="Ascending"/>  
	</Order>
	<SubQueries>
		<Query Name="Orders">
			<Columns>
				<Column Name="Id" />
				<Column Name="ProductId" />
			</Columns>
		    <Order>
				<Order Name="Product.Name" Type="Ascending"/>  
			</Order>
		</Query>
	</SubQueries>
</Query>