Page 1 of 1
OrderSearchCriteria versus OrderFilter classes
Posted: Mon May 23, 2016 9:51 am
by AbleMods
I'm migrating an older Able 7.x install that was heavily customized. It makes use of OrderSearchCriteria.
But in Gold R12, we also have the OrderFilter class.
So, is one better than the other? Should I be migrating the customizations to the newer class?
The code looks pretty similar, I couldn't really see much difference aside from OrderFilter uses a different technique for the keyword search.
Should I be using OrderFilter?
Re: OrderSearchCriteria versus OrderFilter classes
Posted: Mon May 23, 2016 10:18 pm
by mazhar
I think OrderFilter was introduced for data export criteria. Considering you are porting customization you should be using OrderSearchCriteria.
Re: OrderSearchCriteria versus OrderFilter classes
Posted: Tue May 24, 2016 1:53 am
by AbleMods
Ok apparently you guys aren't using OrderSearchCriteria at all
I found a few issues migrating my code:
At the end of ICriteria GetSearchCriteria(OrderSearchCriteria searchCriteria, string sortExpression, bool count), you're testing to see if some child tables need to be joined:
Code: Select all
if (joinOrderShipments) criteria.CreateCriteria("O.OrderShipments", "OS", NHibernate.SqlCommand.JoinType.InnerJoin);
if (joinOrderNotes) criteria.CreateCriteria("O.OrderNotes", "ON", NHibernate.SqlCommand.JoinType.InnerJoin);
The only problem is there is no child class called 'OrderShipments' on the Order class. It got renamed to 'Shipments' when Gold was built. Same thing for OrderNotes. Now it's called 'Notes'.
Easy fix, but necessary if you ever want to use the Search() method with OrderSearchCriteria. Thought you'd want to know.
Re: OrderSearchCriteria versus OrderFilter classes
Posted: Tue May 24, 2016 4:15 am
by mazhar
Nice catch! I just reported this in our logs though I am surprised why no one came across this so far.
Re: OrderSearchCriteria versus OrderFilter classes
Posted: Tue May 24, 2016 4:44 am
by AbleMods
Thanks, I must be the last guy still using it
In the end I found it easier to customize than OrderFilter. My changes involve adding some additional search fields for a few new fields in order shipments. In OrderFilter, this is much harder because you're only bringing in ac_OrderShipments if a keyword is specified. But in OrderSearchCriteria it's designed differently so the optional join is easier to implement.