Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear friend these are my entities

C#
public class FileInformation : Entity
        {            
            
            public string FileName { get; set; }            
            public string FilePath { get; set; }            
            public string Clientid { get; set; }
            public List<ChangeInformation> ChangeInformations { get; set; }
            public FileInformation()
            {
                this.ChangeInformations = new List<ChangeInformation>();
            }
        }
        public class ChangeInformation 
        {
                        
            public string FileName { get; set; }            
            public string OldFileName { get; set; }            
            public long FileSize { get; set; }            
            public DateTime ModifiedDate { get; set; }            
            public string HashValue { get; set; }
            public string DeviceID { get; set; }            
            public DateTime CreationDate { get; set; }            
            public string Status { get; set; }
            public ChangeInformation()
            {

            }
        } 


how i can find all the files whose status in change information are deleted ?

What I have tried:

i have tried following query
var files = finfo.Where(n => n.ChangeInformations.Where(x=>x.Status=="Deleted");
Posted

A Where clause is Func<tinput,bool>. That means that the return must be a boolean. n.ChangeInformations.Where(x=>x.Status=="Deleted") is not a boolean. You should use Any which will return a boolean if any items match the criteria:

C#
var files = finfo.Where(n => n.ChangeInformations.Any(x=>x.Status=="Deleted"));
 
Share this answer
 
Comments
Maciej Los 11-Feb-16 5:01am    
5ed!
This place show you how do this

101 LINQ Samples in C#[^]
 
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