A FetchXml query generates a “Generic SQL Error”, but it works if I switch related objects around?

I am trying to request a vanilla CRM 2015 product catalog, my ultimate goal is to get active products from the price list and name substring, at the moment I am hard-coded my data as follows

PriceLevel: hardcoded GUID
Name: hardcoded "a"

XML Received:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" count="50">
    <entity name="productpricelevel" >
        <attribute name="uomid" />
        <filter type="and">
            <condition attribute="pricelevelid" operator="eq" uitype="pricelevel" value="{7080964d-85df-e411-80ba-00155d0b0c38}" />
        </filter>
        <link-entity name="product" from="productid" to="productid" alias="ac" >
            <attribute name="name" />
            <attribute name="productnumber" />
            <order attribute="productnumber" descending="false" />
            <filter type="and">
                <condition attribute="name" operator="like" value="a" />
                <condition attribute="statecode" operator="eq" value="0" />
            </filter>
        </link-entity>
    </entity>
</fetch>

When I tried to fulfill the request, I received Generic SQL Error. Then I looked at the trace logs and found this:

Exception when executing query: select DISTINCT "productpricelevel0".UoMId as "uomid", "productpricelevel0".UoMIdName as "uomidname", 
coalesce("LL0".Label,"ac".Name ) as "ac.name", "ac".ProductNumber as "ac.productnumber"     
from     ProductPriceLevel as "productpricelevel0" join Product as "ac" 
on ("productpricelevel0".ProductId  =  "ac".ProductId and ( coalesce("LL0".Label,"ac".Name)  like 'a' and "ac".StateCode = 0))     
left outer join BusinessDataLocalizedLabel as "LL0" on ("LL0".ObjectId = "ac".ProductId and "LL0".LanguageId = 1033 and "LL0".ObjectColumnNumber = 6 )     
where     ("productpricelevel0".PriceLevelId = '7080964d-85df-e411-80ba-00155d0b0c38') order by
 "ac".ProductNumber asc 

Exception: System.Data.SqlClient.SqlException (0x80131904): The multi-part identifier "LL0.Label" could not be bound

In an attempt to identify the template, I switched the JOIN around, resulting in this XML:

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" count="50" >
    <entity name="product" >
            <attribute name="name" />
            <attribute name="productnumber" />
            <order attribute="productnumber" descending="false" />
            <filter type="and" >
                <condition attribute="name" operator="like" value="a" />
                <condition attribute="statecode" operator="eq" value="0" />
            </filter>
        <link-entity name="productpricelevel" from="productid" to="productid" alias="ac" >
        <attribute name="uomid" />
        <filter type="and" >
            <condition attribute="pricelevelid" operator="eq" uitype="pricelevel" value="{7080964d-85df-e411-80ba-00155d0b0c38}" />
        </filter>
        </link-entity>
    </entity>
</fetch>

This time I got the results, as expected, no errors.

Sitemap/HTML/JS (, , ), 1033 , , 2 .

?

UPDATE: 2013 . .

+4
1

. , Microsoft , QueryBase T-SQL.

. :

.AddCondition("statuscode", ConditionOperator.In, new object[] { 1, 2, 3 });

QueryExpression , . . Dynamics CRM .

+3

All Articles