我有课,我收集了 FreeDressingItems、FreeToppingItems、FreeInstructionItems
就像这样,每个都填充 selectedCustomization 我在这个类中有另一个属性 public string Items { get { return GetAllItems(); } }
我想填充它,以便它保留同一类别类型的所有类别名称,以便我可以轻松地将其绑定到网格并以逗号分隔的形式显示其所有值。
我有以下代码有人能帮我吗?
public class selectedCustomization
{
public CategoryType TypeName { get; set; }
public string CategoryName { get; set; }
public string ItemName { get; set; }
public int SourceID { get; set; }
public string Items { get { return GetAllItems(); } }
private string GetAllItems()
{
switch (TypeName)
{
case CategoryType.Dressing:
{
cFreeCustomization cfreeCust = new cFreeCustomization();
break;
}
case CategoryType.Topping:
break;
case CategoryType.SpecialInstruction:
break;
}
}
}
这是另一个类 cFreeCustomization
public List<selectedCustomization> SelectedItems
{
get
{
libDBDataContext cn = new libDBDataContext();
List<selectedCustomization> lst = new List<selectedCustomization>();
lst.AddRange(
(from xx in this.FreeDressingItems
select new selectedCustomization() { TypeName = CategoryType.Dressing, CategoryName = xx.DressingInfo.CatName, ItemName = xx.DressingInfo.Description }
).ToList()
);
lst.AddRange(
(from xx in this.FreeToppingItems
select new selectedCustomization() { TypeName = CategoryType.Topping, CategoryName = xx.ToppingInfo.CatName, ItemName = xx.ToppingInfo.Description }
).ToList()
);
lst.AddRange(
(from xx in this.FreeInstructionItems
select new selectedCustomization() { TypeName = CategoryType.SpecialInstruction, CategoryName = xx.InstructionInfo.CatName, ItemName = xx.InstructionInfo.Description }
).ToList()
);
return lst;
}
}
如何以逗号分隔的形式制作 selectedCustomization 的关系?