【发布时间】:2012-12-12 17:01:41
【问题描述】:
我有一个产品列表 (IList<Product>),其中预先填充了所有数据。
型号:Product
public class Product
{
public int Id { get; set; }
public int ParentProductId { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public IList<Product> Children { get; set; }
}
属性Children 将是IList<Product> 类型,意味着它是嵌套的,它可以再次包含高达n 级别的子级。
我有另一个模特FilterModel。
型号:FilterModel
public class FilterModel
{
//// This is same as that of Product Code
public string Code { get; set; }
//// This is a combination of Products Name, Id and some static strings
public string FilterUrl { get; set; }
public IList<FilterModel> Children
}
也有同样的嵌套结构。
我计划将数据从第一个模型 (Product) 插入我的第二个模型 (FilterModel)。这可能以递归方式吗?
【问题讨论】:
-
当您写“可能以递归方式”时,您的意思是您想要每个子产品的新副本?或者使用相同的参考可以吗?
标签: c# .net linq c#-4.0 nested