我收到這個錯誤在我的LINQ的聲明---無法隱式轉換類型System.Collection.Generic.IEnumberable
無法隱式轉換類型「System.Collections.Generic.IEnumerable」到「hcgames.ObjectClasses。 ShoppingCart.ShoppingCartCartAddon」。一個顯式轉換存在(是否缺少強制轉換?)
從這個查詢
ShoppingCartItems items = Cart.GetAllItems();
ShoppingCartCartAddons addons = Cart.GetAllAddons();
var stuff = from x in items
select new ShoppingCartItem()
{
ProductID = x.ProductID,
Quantity = x.Quantity,
Name = x.Name,
Price = x.Price,
Weight = x.Weight,
Addons = (from y in addons
where y.ShoppingCartItemID == x.ID
select y)
};
我無法弄清楚如何正確施放此。有什麼建議麼?
感謝您的幫助!
你可以發佈'ShoppingCartCartAddons'和'ShoppingCartItems.Addons'簽名嗎? – 2010-03-08 13:54:44
namespace hcgames.ObjectClasses.ShoppingCart { [Serializable] public class ShoppingCartItem { public ShoppingCartItem(); public ShoppingCartItem(DataRow dr); public ShoppingCartCartAddons Addons {get;組; } public string CartID {get;組; } public int ID {get;組; } public string Image {get;組; } public string Name {get;組; } public string Price {get;組; } public long ProductID {get;組; } public int Quantity {get;組; } public decimal Weight {get;組; } } } – TheGeekYouNeed 2010-03-08 15:13:47
using System; using System.Collections.ObjectModel; 命名空間hcgames.ObjectClasses.ShoppingCart { [序列化] 公共類ShoppingCartCartAddons:收集 { 公共ShoppingCartCartAddons(); } } –
TheGeekYouNeed
2010-03-08 15:14:57