multi-client-api icon indicating copy to clipboard operation
multi-client-api copied to clipboard

Unrequired _properties on all Controllers

Open kiwiingenuity opened this issue 10 years ago • 1 comments

On all your controllers you have private List _properties = new List(); which you also initiate again further down the page. This property does not appear to be used anywhere?

kiwiingenuity avatar Feb 19 '16 00:02 kiwiingenuity

OK that's not actually an issue, just remove them. It's interesting though to learn where all those came from: In some of the constructors in the controllers we load navigation properties we want to include when querying with Entity Framework Core. For example for the Album entity we have

public static Expression<Func<Album, object>>[] LoadAlbumNavigations()
        {
            Expression<Func<Album, object>>[] _navigations = {
                         a => a.Track,
                         a => a.Artist
             };

            return _navigations;
        }

In the initial implementation though each Load_X_Navigations method had a list of string as a parameter _( properties = new List()) in order to include only the selected navigations depending on the querystring props key. This means that a request to /api/albums/1?props=artistname wouldn't include the respective a => a.Track Expression on the query (optimized) but the /api/albums/1?props=artistname,track(bytes;milliseconds) would. It would be frustrated for the readers though so I removed it. View changes.

chsakell avatar Feb 20 '16 01:02 chsakell