This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have a parent and children object relationship. And wish to retrieve the all the parent objects who have a child object's date within a range AND I wish to retrieve the parent object's in order of the child's date (use MIN(date) in case theres more than one child). How would I go about doing this with LS? |
|
|
Or another question that might solve it for me - is how do i create an object where one of its column's is an SQL aggregate function of a column of its children? |
|
|
You can't do this directly within LightSpeed -- our query engine only supports ordering on an attribute of the parent type. You could potentially handle this externally to LightSpeed by creating a database view (e.g. either by creating a view with the appropriate ORDER BY in its definition, or using your idea of a column which is a SQL aggregate, depending on what data you wanted to include in the parent object). Caveat: In LightSpeed 2.1 RTM, an entity type backs onto exactly one database table or view. So you would not be able to query both a normal "Parents" table and a "SortedParents" view and have them return the same entity type. In current nightly builds, an entity type can be loaded from multiple different tables or views, by specifying the Query.ViewName property. |
|
|
I am in the process of evaluating O/RMs for a business application, and this would be an important feature for our application. Like many applications, we keep our coded fields in separate code tables. So, if we have a business entity like Order, we might have another table with the OrderType, and the SalesPerson, and the State in which the order was placed. The FK relationship is based upon ints, and Lightspeed handles loading the child records nicely when we need to render their details. We are currently showing the description of each of the codes in our grids. However, users need to be able to sort on any of those fields...if you can't sort by description, then all you can do is sort based on the id of the code (which wouldn't necessarily be in alphabetical order). This is easily solved by doing a join, but LS won't do it. I don't see creating a special kind of my entity to handle the sorting as a viable solution, as the O/RM is really supposed to be helping us solve these issued on the domain layer without having to think of wacky work-arounds like this. If I implemented that solution and decided to switch persistence frameworks (perhaps one that does support this), I'd be stuck with all these entities that don't add any value to my domain model. They muck it up. I suppose this could be handled more easily with Views support (it sounds like that's in the development build), but if you wanted to map a view to an entity you have to make sure your views are modifiable and any potential issues that go along with that. |
|