gpt4 book ai didi

c# - 无法将 IList 转换为绑定(bind)列表

转载 作者:行者123 更新时间:2023-11-30 22:04:25 25 4
gpt4 key购买 nike

我正在开发一个将 Object 转换为 IList 的应用程序。然后我想将它转换为 BindingList

这是我正在尝试的代码

IList data = spareEntity.getall() as IList;
var listBinding = new BindingList<IList>(data);

public object getall()
{
using (var worldbankAMSentitiesNew = new WorldBankAMSEntities())
{
var q = from fullSpareInventory in worldbankAMSentitiesNew.Spare_Inventory
select new
{
fullSpareInventory.Is_Spare,
fullSpareInventory.Manufacturer,
fullSpareInventory.Product_No,
fullSpareInventory.Remarks,
fullSpareInventory.Remedy_Ticket_No,
fullSpareInventory.Serial_No,
fullSpareInventory.Spare_Type,
fullSpareInventory.Spare_Inventory_Volume.Spare_Name,
fullSpareInventory.Spare_ID,
fullSpareInventory.Assigned_Date,
fullSpareInventory.Description,
fullSpareInventory.Spare_Volume_ID
};
return q.ToList();
}
}

最佳答案

你可以尝试如下:-

var yourList = spareEntity.getall() as List<Object>;
var listBinding = new BindingList<Object>(yourList);

关于c# - 无法将 IList 转换为绑定(bind)列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25262784/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com