2

I am using EF 7 with the query as below.

var query = db.Contracts
                    .Include(s => s.ContractType).ThenInclude(s => s.Header)
                    .Include(s => s.ContractUsers).ThenInclude(s => s.User)
.AsQueryable();
query = query.OrderBy(s=>s.EffectiveDate).ToList();

Above query is returning results with ContractUsers collection as empty but ContractType filled out. If I remove OrderBy query, then it returns the ContractsUsers collection. It's strange, can someone help me how to fix this? I need to have the ordering done in sql.

Camilo Terevinto
  • 26,697
  • 6
  • 67
  • 99
TSR
  • 678
  • 2
  • 7
  • 21
  • 2
    I recall see something very similar being logged on github for Entity-framework E7 current release. So what I am saying is it is a known bug.. and will probably be fixed... soonish. As you are not filtering them...you could just do the order by in memory. This assumes that there isnt more to the puzzle. If there is you could see if you could do it in memory for now... until bug is fixed.. it was marked as critical 0, 0 being the highest. – Seabizkit Feb 17 '16 at 07:32
  • Can you point to me to the issue please? couldn't find it on git page. – TSR Feb 17 '16 at 07:48
  • sozs i think you are correct could not find it either... maybe you should log one ;-) – Seabizkit Feb 17 '16 at 07:56
  • 2
    Saying that there seems to be a lot closed in RC2... can you get that build and try it...https://github.com/aspnet/EntityFramework/issues/4085 as and example of ones fixed in RC2 – Seabizkit Feb 17 '16 at 07:58
  • Is this actually fixed per @Seabizkit comment? – Braiam Oct 08 '17 at 02:31
  • @Braiam the probability of this being fix after a year and with the release is v2.0 now compared to RC2, and the bug saying its closed. I would say 99.99 % that its fix. by i cant say for 100 as i am using v6.13. This is about ef core which was heaving in early stages of development and still is. Maybe the title should change so others know this is about EF Core and not the other version just EF – Seabizkit Oct 08 '17 at 12:15
  • Yep, can safely be closed as non-reproducible (in ef-core 2.0.0). – Gert Arnold Oct 08 '17 at 18:09

0 Answers0