我有2个表CampaignCoverage和Coverage
CampaignCoverage有一个CoverageID列。覆盖范围有一列DateX。
基本上我没有在代码中指定CampaignCoverage.CoverageID = Coverage.ID就像你在SQL中那样。这是怎么回事???? !!!!
CampaignCoverageCollection campaignCoverages =
new Select()
.From(Tables.CampaignCoverage)
.InnerJoin(Tables.Coverage)
.Where(Coverage.DateXColumn).IsGreaterThan(ucDateStart.DateTime)
.And(Coverage.DateXColumn).IsLessThan(ucDateEnd.DateTime)
.And(CampaignCoverage.CampaignIDColumn).IsEqualTo(campaign.Id)
.ExecuteAsCollection<CampaignCoverageCollection>();
答案 0 :(得分:1)
如果你没有指定CampaignCoverage.CoverageID是Coverage.ID的外键(我认为这就是你想说的话),那么摆脱连接应该可以解决问题。即删除
.InnerJoin(Tables.Coverage)
也就是说,您可能希望将CampaignCoverage.CoverageID设为Coverage.ID的外键。执行此操作后,您可以删除IsEqualTo子句。即删除
.And(CampaignCoverage.CampaignIDColumn).IsEqualTo(campaign.Id)