views:

44

answers:

1

I've have 2 tables CampaignCoverage and Coverage

CampaignCoverage has a CoverageID column. Coverage has a column DateX.

Basically I've not specified in the code that CampaignCoverage.CoverageID = Coverage.ID like you would to in SQL. How does this work at all????!!!!

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>();
+1  A: 

If you have not specified that CampaignCoverage.CoverageID is a foreign key to Coverage.ID (I think that is what you are trying to say), then getting rid of the join should do the trick. i.e. Remove

.InnerJoin(Tables.Coverage)

That said, you probably do want to make a CampaignCoverage.CoverageID a foreign key to Coverage.ID. After you do that, you can get rid of the IsEqualTo clause. i.e. Remove

.And(CampaignCoverage.CampaignIDColumn).IsEqualTo(campaign.Id)
sparks