Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
existingCostShare.Costshare = existingCostShare.Costshare.Where(c => result.Personnel.All(p => c.BaseCostShareProjectPerson?.Hrn == p.BasePerson?.Hrn || c.BaseCostShareTbdPerson?.Hrn == p.BasePersonnelTbdRole?.Hrn));

What I have tried:

existingCostShare.Costshare = existingCostShare.Costshare.Where(c => result.Personnel.All(p => c.BaseCostShareProjectPerson?.Hrn == p.BasePerson?.Hrn || c.BaseCostShareTbdPerson?.Hrn == p.BasePersonnelTbdRole?.Hrn));
Posted
Updated 22-Jan-23 2:42am
Comments
0x01AA 22-Jan-23 8:58am    
What boolean value you would expect if e.g. for c.BaseCostShareProjectPerson?.Hrn == p.BasePerson?.Hrn the left or the right hand side or both is null?

To be more precise, what do you expect what the results should be
1. undefined == defined
2. undefined == undefined

And moreover, what should happen when concatenating such results with e.g. or, what should be the results for ...
1. undefined or defined
2. undefined or undefined
Richard Deeming 23-Jan-23 6:04am    
One of the controversial decisions that Microsoft took when nullable types were first introduced is that, unlike SQL, null == null returns true, and null == (not null) returns false. There is no three-valued logic around null comparisons.

But that might be the cause of the problem: if p.BasePerson?.Hrn is null, then the query will return all records where c.BaseCostShareProjectPerson?.Hrn is null; and similarly for p.BasePersonnelTbdRole?.Hrn and c.BaseCostShareTbdPerson?.Hrn.

But as Griff said, without access to the data, we can only guess.
0x01AA 23-Jan-23 6:59am    
Thank you very much for this explanation. Appreciated very much.

1 solution

Without your database there isn't a lot we can do: it's not obvious without data what you are expecting or getting.

So start by looking at your input data and your output results - identify the elements you don't want and look at the original data to find out what they have in common. Then use that to look at what data was not included and what should have been: why were those rows included when they should not have been?

When you understand that, you can look at writing a query to get just the data you do want - but until then you are just guessing and hoping it will work.

Sorry, but we can't do any of that for you!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900