在通过 Linq 将两个列表进行比较之后,我想准备一个 CampaignDetails 类型的列表。您可以在下面看到代码片段:
List<CampaignDetails> str = service.GetActiveCampaignBySubCatId(lang, subCatId); //List1
List<CampaignDetails> sploffer = service.GetSpecialOfferCampaignsForMobile(lang); // List2
List<CampaignDetails> CampList = new List<CampaignDetails>();
foreach (var data in str)
{
var CampL = (from offer in sploffer
where offer.CampaignId != data.CampaignId
select offer).ToList();
CampList.Add(CampL); // getting red mark here
}
CampaignDetail 类:
public class CampaignDetail
{
public int CampaignId { get; set; }
public string CampaignName { get; set; }
public string CampaignHeading { get; set; }
public decimal OfferPrice { get; set; }
public string CampaignDescription { get; set; }
}
这里出了什么问题?我无法根据上面的代码片段过滤列表。我在以下位置收到编译器警告CampList.Add(CampL);
:
'System.Collections.Generic.List.Add(CampaignDetails)-Method' 的最佳重载方法匹配有一些无效参数。