Select parent element given child id

Jun 13, 2014 at 10:25 AM
Edited Jun 13, 2014 at 10:28 AM
I have created a query that gets a list of files and each file has properties.
I want to check each id of each property of each file and if it matches i want to show the original file object.
var id = 2;
var query = Enumerable.From($scope.files)
            .SelectMany(function (file) {
                return Enumerable.From(
                    .Select(function(property) {
                        if ( == id)
                            return file;
This works but return an array of objects and the objects that did not match are in array as undefined which i need then to clear by another iteration.

Is there a better way?