Sorting on Column in Type Table with ColdFusion ORM

扶醉桌前 提交于 2019-12-01 03:09:37

I solved this one with Sam's help, by setting up a method in my Service that returned the items in the order I wanted. I just used ORMExecuteQuery to get the items in the right order, and if there were no items, just returned an empty array.

The final method looked like this, where specifications are set directly in the object in the order I want them:

/**
@hint Gets a SpecGroups object based on ID. Pass 0 to retrieve a new empty SpecGroups object
@ID the numeric ID of the SpecGroups to return
@roles Admin, User
*/
remote ORM.SpecGroups function getSpecGroup(required numeric ID){
    if(Arguments.ID EQ 0){
        return New ORM.SpecGroups();
    }else{
        LOCAL.SpecGroup = EntityLoadByPK("SpecGroups", Arguments.ID);
        LOCAL.SpecsInGroup = ORMExecuteQuery("SELECT Spec FROM SpecInGroup G WHERE G.SpecGroupID = :GroupID ORDER BY SpecLabel, SpecName", {GroupID = LOCAL.SpecGroup.getID()});
        LOCAL.SpecGroup.setSpecifications(LOCAL.SpecsInGroup);
        return LOCAL.SpecGroup;
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!