Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

Hi,
I am not sure if my expression is correctly. Correct me if anything syntax is wrong.

This has to filter by PipelineName = Utility (This following code is not filtering by utility)
I am expecting it should pull only for those utility we are passing as a parameter.
I can understand it is difficult to provide solution with the information provided but, this is what I have.
Any information is appreciable.

C#
// utility (pipeline)
            if (!string.IsNullOrWhiteSpace(utility))
            {
                submissions = submissions.Where(s => s.SummaryBillMaster.BillingGroupFacilityCollection.Select(f => f.Facility).Select(d => d.DealCollection.Select(p => p.Pipeline.PipelineName == utility  && p.Period == s.Period)).Any());
            }






Thanks!

What I have tried:

// utility (pipeline)
if (!string.IsNullOrWhiteSpace(utility))
{
submissions = submissions.Where(s => s.SummaryBillMaster.BillingGroupFacilityCollection.Select(f => f.Facility).Select(d => d.DealCollection.Select(p => p.Pipeline.PipelineName == utility && p.Period == s.Period)).Any());
}
Posted
Updated 21-Mar-16 11:55am
v7
Comments
Sergey Alexandrovich Kryukov 21-Mar-16 17:22pm    
Did you see how your code looks after posting? You screw up just HTML formatting. I tried to fix it, but I could not be 100% sure that the fragment with '&&' operator is what you mean to write). Please check up that the posted code is the same as the one you have problems with.
—SA
Cyrus_Vivek 21-Mar-16 17:42pm    
Hi SA,

Sorry was not aware. Idk how it took HTML format into it., just saw the versions you made changes. Thanks!
Cyrus_Vivek 21-Mar-16 17:46pm    
Does this make sense now??
Sorry for earlier post!
-Cyrus

1 solution

C#
Select() method works as projection. So it always will return class with properties.
so your lambda expression should look like by that way

if (!string.IsNullOrWhiteSpace(utility))
{
      submissions = submissions
          .Where(s => s.SummaryBillMaster.BillingGroupFacilityCollection
              .Where(p => p.Pipeline.PipelineName == utility && p.Period == s.Period))
              .Select(f => f.Facility.DealCollection)
              .Any()
          );
}
 
Share this answer
 
Comments
Cyrus_Vivek 22-Mar-16 9:33am    
I haven't tried this out yet. Will try it and let you know.
"Select() method works as projection. So it always will return class with properties."
This piece of line was informative. Thanks!
Cyrus_Vivek 22-Mar-16 16:02pm    
So, I tried. here is the thing.
if (!string.IsNullOrWhiteSpace(utility))
{
submissions = submissions
.Where(s => s.SummaryBillMaster.BillingGroupFacilityCollection
.Where(p => p.Pipeline.PipelineName == utility && p.Period == s.Period))
.Select(f => f.Facility.DealCollection)
.Any());
}

this is not working because Facility is in BillingGroupFacilityCollection.
and DealCollection is in Facility.
DealCollection is a ICollection.

Any ideas?
Cyrus_Vivek 22-Mar-16 16:21pm    
The expression which I have is working fine., except that the filter was giving all the records. Meaning filter was not working!
Cyrus_Vivek 23-Mar-16 14:54pm    
I feel, the expression itself is working fine., but the data before getting into this point, is not appropriate. However, thanks v7777 for making few corrections in the expression, which actually did help me.
-Cyrus

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