How to Put the following query result into a List
var result = from c in sb.Swithches_SW_PanalComponents
select new { c.ID,c.SW_PanalComponents.ComponentsName,c.ComponentValue };
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
FINAL EDIT
Based on your last comment, this is all you ever needed
which of course is identical to
EDIT
Based on your comments, I think this is what you want:
END EDIT
The
ToListmethod is what you want. But consider using dot notation. For simple queries like this, it’s much cleaner and trimmer.Also note that, if you’re just trying to execute your query immediately, and only need to enumerate over it, you can also call
AsEnumerable()The advantage here is that result is a less specific type—
IEnumerablt<T>.