C# 选择“新建”时需要填充集合的子集合
除了试图用数据填充子集合的区域外,我的Linq查询中的所有内容都正常工作。任何引用频道信息的东西 ChannelInfo确实出现在Intellisense中,因此它被识别为新OfferType的属性。我的ChannelInfo设置器的右侧也可以在intellisense中识别和访问。如果可能的话,我真的需要创建新的OfferType对象。我是否可以引用子连接ChannelInfo以使此查询正常工作C# 选择“新建”时需要填充集合的子集合,c#,linq,C#,Linq,除了试图用数据填充子集合的区域外,我的Linq查询中的所有内容都正常工作。任何引用频道信息的东西 ChannelInfo确实出现在Intellisense中,因此它被识别为新OfferType的属性。我的ChannelInfo设置器的右侧也可以在intellisense中识别和访问。如果可能的话,我真的需要创建新的OfferType对象。我是否可以引用子连接ChannelInfo以使此查询正常工作 IEnumerable<OfferType> list = (from offerCa
IEnumerable<OfferType> list = (from offerCatType in offerRes.OfferCategory <=---- OfferCategoryType objects
where offerCatType.type == Type
from offers in offerCatType.Offer <=--- OfferType objects
where Convert.ToDateTime(offers.startDate) > MonthYear && Convert.ToDateTime(offers.endDate) < MonthYear
select new OfferType
{
name = offers.name,
description = offers.description,
startDate = offers.startDate,
endDate = offers.endDate,
ChannelInfo.refClickThroughLink = offers.ChannelInfo.refClickThroughLink,
ChannelInfo.refId = offers.ChannelInfo.refId,
ChannelInfo.refLink = offers.ChannelInfo.refLink
}
);
请原谅语法错误。但是,您必须重新设置ChannelInfo类。谢谢。当然,我尝试了不同的版本!
select new OfferType
{
name = offers.name,
description = offers.description,
startDate = offers.startDate,
endDate = offers.endDate,
ChannelInfo =
new ChannelInfo
{
refClickThroughLink = offers.ChannelInfo.refClickThroughLink,
refId = offers.ChannelInfo.refId,
refLink = offers.ChannelInfo.refLink
};
}