Monday, 30 June 2014

LINQ



Populating data-rows into a collection list (Class)



    public class TaskStep
    {
        public int stepId {get; set;}
        public string stepName {get; set;}
        public string connectionString {get; set;}

    }

-------
                List<TaskStep> taskSteps = steps.Rows
                .Cast<DataRow>()
                .Select(row => new MyDomain.Client.Data.TaskStep
                {
                    stepId = (int)row[0],
                    stepName = (string)row[1],
                    connectionString = (string)row[2]

                })
                .ToList();

No comments:

Post a Comment