Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> Sort EntityView on a related field
 

Pages: 1
Bugs & Issues
Sort EntityView on a related field
Page:1/1 

  Print all messages in this thread  
Poster Message
Brandt
User



Location:

Joined on:
04-Apr-2007 17:43:03
Posted:
142 posts
# Posted on: 25-Jun-2009 18:27:50.  
LLBLGEN 2.6
ORM Support classes version 2.6.09.0305

Problem : After defining a field on related field ( 1:1 relation ship - the field is a string) and using the LLBLGENDataSource2 (adapter), I am getting an ORMInterpretationException : The expression has just 1 operand and the operand is null when trying to use the e.Sorter in the PerformSelect event. It only happens when trying to sort by the related field and not the other ones. The exception is thrown in the code segment that is highlighted in green. I have checked the sorter and it has the correct sort expression in it.

Thanks,
Brandt

Code:



        protected void DS_CurrentSchedules_PerformSelect(object sender, SD.LLBLGen.Pro.ORMSupportClasses.PerformSelectEventArgs2 e)
        {
            if (this._pageController.Item != null)
            {
                var col = this._pageController.Item.CurrentOnCallScheduleCollection;
                [colorvalue="00CC00"]col.Sorter = e.Sorter;[/color]
                foreach (var ent in col)
                {
                    e.ContainedCollection.Add(ent as EntityBase2);
                }
            }
        }


    public partial class ContactGroupEntity
    {

        public EntityView2<OnCallScheduleEntity> CurrentOnCallScheduleCollection
        {
            get
            {
                return new EntityView2<OnCallScheduleEntity>(OnCallScheduleCollection, OnCallScheduleFields.EndDate > DateTime.Now);
            }
        }

        public EntityView2<OnCallScheduleEntity> PastOnCallScheduleCollection
        {
            get
            {
                return new EntityView2<OnCallScheduleEntity>(OnCallScheduleCollection, OnCallScheduleFields.EndDate < DateTime.Now);
            }
        }
    }



Brandt  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8150 posts
# Posted on: 25-Jun-2009 20:13:47.  
Hi Brandt,

What is on e.Sorter when it fails?
Is the related collection prefetched (there are items in the 1:1 related entity).


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Brandt
User



Location:

Joined on:
04-Apr-2007 17:43:03
Posted:
142 posts
# Posted on: 25-Jun-2009 20:16:33.  
daelmo wrote:
Hi Brandt,

What is on e.Sorter when it fails?

Is the related collection prefetched (there are items in the 1:1 related entity).


It is has a sortexpression with an entityfield and a descending sortorder. The entityfield has the correct name MemberName.

The related collection is prefetched.
Brandt  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8150 posts
# Posted on: 25-Jun-2009 20:53:41.  
Please try using EntityProperty when sorting on related entities. (more info...).

Example:
Code:
ISortExpression sorter = new SortExpression();
sorter.Add(new EntityProperty("EmployeeName") | SortOperator.Ascending);

EntityView2<OrderEntity> ordersView = new EntityView2<OrderEntity>(orders);
ordersView.Sorter = sorter;




David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Brandt
User



Location:

Joined on:
04-Apr-2007 17:43:03
Posted:
142 posts
# Posted on: 26-Jun-2009 14:40:37.  
daelmo wrote:
Please try using EntityProperty when sorting on related entities. (more info...).

Example:
Code:
ISortExpression sorter = new SortExpression();
sorter.Add(new EntityProperty("EmployeeName") | SortOperator.Ascending);

EntityView2<OrderEntity> ordersView = new EntityView2<OrderEntity>(orders);
ordersView.Sorter = sorter;





Ok that helped lead me to a solution. The LLBLGENDataSource2 had to be set to client side sorting and then it worked. Thanks
Brandt  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.