Solved

Changing LINQ to XML to Lambda to XML

Posted on 2010-11-20
2
393 Views
Last Modified: 2012-06-27
Can I write these using a Lambda expression?:

            var query = from xElem in doc.Descendants("Patient")
                        select new Patient(xElem);


            XElement xml = new XElement("Patients",
                from p in this
                select p.XElement);
0
Comment
Question by:newbieweb
2 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 34181530
No, lambda expressions themselves are not a replacement for LINQ. I think that you mean extension methods, which use lambda expressions as part of the syntax:

var query = doc.Descendants("Patient").Select(xElem => new Patient(xElem);

XElement xml = new XElement("Patient", this.Select(p => p.XElement));

Open in new window

0
 

Author Closing Comment

by:newbieweb
ID: 34181590
Thanks a lot!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question