Retrive value var datatype using linq

Binumon George 161 Reputation points

Hi all,

      below I am giving one code to retrieve value from Var datatype. But now I can access only one column only.

     List<string> ABC;
       var result = tx.Run("MATCH (a:Person)  RETURN,a.age ORDER BY");

                 abc = result.Select(record => record[0].As<string>()).ToList();

If we look into the code I am storing and a.age to the result variable. But now I can retrieve only one column from result variable to abc variable. if I want to retrieve more than one or two columns from the result variable what changes want to do?

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,959 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Jack J Jun 24,266 Reputation points Microsoft Vendor

    @Binumon George , I recommend that you use select new method to get many columns from the result.

    Here is a code example you could refer to.

     class Program  
            static void Main(string[] args)  
                List<Person> list = new List<Person>();  
                list.Add(new Person { Name="test1",Age=22 });  
                list.Add(new Person { Name="test6", Age=20 });  
                list.Add(new Person { Name="test3", Age=21 });  
                list.Add(new Person { Name="test9", Age=22 });  
                var result = from t in list  
                             orderby t.Name  
                             select new  
                foreach (var item in result)  
            public class Person  
                public string Name { get; set; }  
                public int Age { get; set; }  



    If I have some misunderstanding, Please feel free to let me know.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. Binumon George 161 Reputation points

    Hi Jack
    The below-attached output of the above code.