我怎样才能从另一个班补课呢
本文关键字:另一个 补课 | 更新日期: 2023-09-27 18:26:22
我有一个类,其中我有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的链接?
我认为方法GetAllItems
应该如下所示:
private string GetAllItems()
{
cFreeCustomization cfreeCust = new cFreeCustomization();
var ls = cfreeCust.SelectedItems.FindAll(I => I.TypeName == this.TypeName);
return string.Join(",", ls.Select(I => I.CategoryName).ToArray());
}
这将解决您的问题。