Using LINQ to select hierarchical data?

DataTable dt = new DataTable() //Other DT stufff //LINQ Query var data = from t in table select t; //Loop to create DT foreach (item in data.ToList()) { DataRow dr = new DataRow(); dr"Parent" = item. Name; dr"Child" = item.item. Name; //Where item.

Item is your FK relation to itself dt.Rows. Add(dr); }.

I prefer to keep the joins as joins var result = from t1 in table join t2 in table on t1. Id = t2. Parent select new { parent = t1.Name, child = t2.

Name }.

Data. Select(d => d. Parent).

Select(p => p. Property).ToList(); select will just project the results back to you lazy loaded. So simple select what you need into either a local list, or with a little syntax you can use the anonymous projection to bottle all the levels of data together and filter on that before .ToList()'ing back to ya.

Var result = source. Select(child => new { Child = child, Parent = source. SingleOrDefault(parent => parent.ID == child.

Parent) }).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions