Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I have develop some small application, which in i want to get data from linq query which in I have bind using
C#
public List<FileDescription> lstFile = new List<FileDescription>();
model.

and here, is one linq query which getting all data which I want.
C#
var lstFileDesc = (from p in appConDesc.lstFile where p.FileID == FileID select p);
           if (lstFileDesc.Count() >= 1)
           {
               fileName = lstFileDesc.Single().FileName;
               fileType = lstFileDesc.Single().FileType;
           }


Above, In lstFileDesc variable i get all data which is getting from linq query, but in if condition they are not inserted,means that data are getting to different method.


Thanks,
Posted
Comments
Anisuzzaman Sumon 25-Dec-15 12:45pm    
Please clarify your question.

1 solution

Not sure i understand you well, but... you probably want to get only FileName and FileType as an result instead of all properties of p object.

C#
var lstFileDesc = appConDesc.lstFile
                        .Where(p=>p.FileID==FileID)
                        .Select(p=>new{FileName = p.FileName, FileType = p.FileType});
 
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