Lenkelheit / Coursework

This repository contains Instagram-like application
Apache License 2.0
1 stars 0 forks source link

Convert ObserveableCollection to List #123

Closed iamprovidence closed 5 years ago

iamprovidence commented 5 years ago

In Project/DataAccess/Context/AppContext.cs inside SaveChanges method we convert ObserveableCollection to IQueryable and then to List. I do not see reason why we do so. Should be check if it works without ToList method, it might save up times

also we have

PhotoLike.Local.Where(ph => ph.Photo == null && ph.User == null).ToList().ForEach(ph => PhotoLike.Remove(ph));

maybe this one would be faster, because in this way we do not search for each entity

PhotoLike.Local.Where(ph => ph.Photo == null && ph.User == null).ToList().ForEach(ph => Entry(ph).State=EntityState.Deleted);

or even with SQL But we should try this after all test has been successfully passed with current code version