weird issue with linq after hotfix

lawrence whittemore asked on February 7, 2023 14:04

Has anyone else notice any issues with LINQ queries returning null after the hotfix?

  var quickLink = _ctxOld.QuickLinks
             .Where(item => item.UserId == userid)
             .FirstOrDefault(item => item.ItemID == QuickLinkID);
  var quickLink2 = _ctxOld.QuickLinks
            .OrderByDescending(item => item.LinkOrder)
            .Where(item => item.UserId == userid)
            .FirstOrDefault(item => item.LinkOrder < quickLink.LinkOrder);

So, these were working fine before the hotfix, but after they sometimes fail when the results should be there. Any thoughts on what might have changed in the hotfix? went from 95 to 99.

I was able to fix it by using a different type of query and a repository.

Recent Answers

Brenden Kehren answered on February 7, 2023 17:23

Are you sure it's a Kentico issue and not a .NET or C# version issue? What version of C# and .NET is your project?

Also, are you positive the data is supporting your query and actually bringing data back?

0 votesVote for this answer Mark as a Correct answer

lawrence whittemore answered on February 7, 2023 18:37

You know what, I think it has to do with a new field that I added that was not nullable. I think I remember something like this happening before with EF. When the field returns null when it is not set to nullable the whole query fails.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.