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 firstname.lastname@example.org
I'm not sure if this task is much about LightSpeed, but I'm trying to solve this in LS mantinels (though they are wide enough) so I hope you won't be angry at me.
I have a Product class and abstract Rate class. This Rate class is implemented by RateByValue and RateByTermAndValue classes. An usual Strategy pattern:
abstract class Pattern has Compute(decimal Value) method, so I can call:
But in my design, the Product has got a collection of Rates. The collection of RateByValue class instances OR the collection of RateByTermAndValue class instances. Never mixed.
My problem is how to query the collection Product.Rates in method also by a Term property if the collection items are of the right type?
One way would be test the type of first item in the collection, but it does not seems right to me.
Usually I would write a Stored Procedure returning the whole row (it is Single Table Inheritance) and by RateType decide which class to instantitate. But can I instantiate entities by hand and fill them by values from SP?
I'm able to architecture design changes, I just need this shortcomming walk around.
Thank you, Pooik
Hmm, I am not sure I entirely understand what you're trying to do here. Is it that you want to get the RateByTermAndValue objects associated with a given product where the Term has the given value? Ignoring any RateByValue objects if there are any?
If so, if the Rates collection is loaded or small you can use LINQ to Objects:
If you want to execute the query on the database using LINQ to LightSpeed:
If I've misunderstood the question, please let me know!