0

i'm using this code

 public List<T>  GetWithNavigationTo(params string[] pathes)
        {
            (this._context as DbContext).Configuration.LazyLoadingEnabled = false;
            (this._context as DbContext).Configuration.ProxyCreationEnabled = false;
            var data = Entities.AsQueryable();
            if (pathes != null)
            {
                foreach (string path in pathes)
                {
                    data = data.Include(path);
                }
            }
            return data.ToList();
        }

To Load Entities With Specified Navigation Path the problem is when i add navigation path i got some data loss i mean that some entities are not retrieved any solutions?

Hasan Elsherbiny
  • 598
  • 2
  • 14
  • 31
  • 2
    Please be more specific... give example include paths and example data, be specific about what you expect and what you get. – grek40 Sep 04 '17 at 13:50
  • 2
    What SQL got [logged](https://stackoverflow.com/questions/16880687/how-can-i-log-the-generated-sql-from-dbcontext-savechanges-in-my-program)? – Steve Greene Sep 04 '17 at 15:05
  • @SteveGreene the problem solved thanks –  Sep 04 '17 at 23:24

1 Answers1

1

I solved the problem after revising SQL profiler. I saw that the query was generated using an inner join for the navigation properties, because the relation was required (non null values). So after allowing foreign key to be null, I got a left join, retrieving all values as I wanted.

grek40
  • 13,113
  • 1
  • 24
  • 50