3 01 2008

Say we have a class,

public class Student
    private String name;
    private string course;

    public string Name

        get { return name; }
        set { name = value; }


    public string Course

        get { return course; }
        set { course = value; }


    public Student(string name, string course)
    { = name; 
        this.course = course;



List<Student> list = new List<Student>()
    new Student("a","course"),
    new Student("b","course1"),
    new Student("c","course2"),
    new Student("d","course3"),
    new Student("e","course4")

To use LINQ,

IQueryable<Student> StudentEntity = list.AsQueryable<Student>();

string studentName = (from s in StudentEntity
                      where s.Course == "course1"
                      select s).First().Name;

Console.WriteLine("Studnet Name : {0}", studentName);

The catch is that we convert the generic list to IQueryable<T> type which enables us to query against objects 🙂




One response

27 03 2013

Hi I have fallowing xelement

i want to retrive inner conetent of Sap how can i retrive the o/p as xlement?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: