Retaining order with LINQ using .Contains
|Added at||2017-01-02 11:01|
I have read this question about retaining order in a list, but I didn't see anything about using the
I have created a wrapper class which can contain different objects, like below:
I have a method which orders a list, regardless of the type of object. Before I call the method which orders this list, I retrieve the objects from my database and map them to
I have succesfully done this, but for the sake of readability, I would like to use LINQ in my entire method. Currently, I'm setting up my output list like this:
In this example is
I have tried the following, but it doesn't retain the order the filtered list has. This is very important, since the list is a top 10 of recommendations.
Is there a way I can use LINQ and still retain the order of the filtered list?
Please let me know if I need to provide more information!