Load operation failed with orderby, not when using SortDescriptor

Posts   
 
    
ABOH
User
Posts: 148
Joined: 06-Sep-2011
# Posted on: 15-Jan-2012 04:56:57   

Hello,

We have a Silverlight RIA application that is using a DomainDataSource that is bound to a DataGrid. We are using LLBLGEN as our DAL layer. When I create the following query in our DomainService.cs code, which orders the results by ClientLabel, ascending, the DataGrid throws a DomainOperatonException:

"Load operation failed for query 'GetMikesCustomers'. An exception was caught during the execution of a retrieval query: A column has been specified more than once in the order by list. Columns n the order by list must be unique."

As you can see in the following query, there is only a single column listed.

When I remove the orderby from the query, and add a SortDescriptor to the definition of the DomainDataSource in our XAML code, then everything is fine.

I can rework all of my queries so ordering is done via XAML, but I am wondering whether you have any ideas as to why this exception is being thrown.

Is there any performance penalty to use the SortDescriptor rather than an "orderby"?

Thank you for your help!

Mike

=======================================================================
        [Query]
        [RequiresAuthentication]
        public IQueryable<CustomerEntity> GetMikesCustomers()
        {
            IQueryable<CustomerEntity> entities = null;
            DataAccessAdapter adapter = new DataAccessAdapter();

            if (adapter == null)
            {
                throw new NullReferenceException(string.Format(ABitOfHelp.ExpirationTrax.Shared.Resources.Errors.CannotDereferenceNullValue, "adapter"));
            }

            LinqMetaData linq = new LinqMetaData(adapter);
            if (linq == null)
            {
                throw new NullReferenceException(string.Format(ABitOfHelp.ExpirationTrax.Shared.Resources.Errors.CannotDereferenceNullValue, "linq"));
            }

            entities =
                (from c in linq.Customer  
                [b]orderby c.CustomerLabel ascending[/b]                
                 select c);

            return entities;
        }
=====================================================================

        <riaControls:DomainDataSource
            x:Name="customersDomainDataSource"
    AutoLoad="True" 
    LoadSize="50"
    d:DesignData="{d:DesignInstance dal:CustomerEntity, CreateList=true}" 
    Height="0" 
    LoadedData="CustomersDomainDataSource_LoadedData"                       QueryName="GetMikesCustomersQuery" 
            SubmittedChanges="CustomersDomainDataSource_SubmittedChanges" Width="0">
            <riaControls:DomainDataSource.DomainContext>
                <my:ExpirationTraxDomainContext />
            </riaControls:DomainDataSource.DomainContext>
[b]         <riaControls:DomainDataSource.SortDescriptors>
    <riaControls:SortDescriptor PropertyPath="CustomerLabel" Direction="Ascending" />
        </riaControls:DomainDataSource.SortDescriptors>[/b]     </riaControls:DomainDataSource>
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 15-Jan-2012 22:47:05   

SortDescriptor is the RIA way of doing this: http://blogs.msdn.com/b/bursteg/archive/2009/04/08/build-a-simple-application-with-net-ria-services-silverlight-3-part-2.aspx

Inspect the generated queries to ensure the correct ones are sent to the DB.

David Elizondo | LLBLGen Support Team
ABOH
User
Posts: 148
Joined: 06-Sep-2011
# Posted on: 16-Jan-2012 00:44:27   

Hi Daelmo,

Thanks for your posting. I understand using RIA and its SortDescriptor, but I cannot explain why the error message reports that there are duplicate columns when using the orderby. Especially when the select statement is as simple as I have posted.

When I don't use a SortDescriptor, and supply a single column in the orderby, I get the error message.

When I remove the orderby from our linq, and use a SortDescriptor, the error disappears.

This is strange behavior, which is why I was asking for help... Since the RIA way works and the linq way fails, I don't know whether this means that something may be amiss in my LLBLGEN generated DAL.

Is there any difference in query performance using a RIA SortDescripitor or an orderby with LLBLGen's DAL?

Your idea about reviewing generated queries is a good one... Can you please tell me how to do this with LLBLgen, and any other suggestions.

Thank you for your help! Mike

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 16-Jan-2012 09:52:32   

Please check the following documentation link: DQE Tracing

Basically all you have to do is add the following to your application config file, run the application in debug mode, and check V.S. output window:

<system.diagnostics>
    <switches>
        <add name="SqlServerDQE" value="4" />
    </switches>
</system.diagnostics>

I need you to not Sort by Linq, nor to use the SortDescriptor, and inspect the generated query. I suspect that a default SortDescriptor is being passed.