类
public class category {
int Id { get; set; }
string c_name { get; set; }
}
public class item {
int id { get; set; }
string item_name { get; set; }
int category_id { get; set; }
}
记录
// | id | c_name | | id | item_name | category_id |
// | 1 | fruit | | 1 | apple | 1 |
// | 2 | electronic| | 2 | banana | 1 |
// | 3 | rice cooker| 2 |
如何在列表中加入Linq
并在树状结构中显示?
var c = new List<category>();
var i = new List<item>();
答案 0 :(得分:0)
您可以加入以下表格:
var q = from ci in c
join ii in i on ci.id equals ii.id
select new { category = ci, item = ii};