Join Tables

Topics: Developer Forum
Feb 15, 2008 at 4:31 AM
Hello,

I have 2 tables, Companies and Applications and a join table Company_Applications. I want to be able setup this relation in the abstract classes but am not sure how to. In Rails, I'd usually do this via the :through attribute like:

class Company < ActiveRecord::Base
hasmany :companyapplications, :dependent => true
hasmany :applications, :through => :companyapplications
end

What would be the best way for me to setup this relationship? Thanks in advance!

DB Schema looks something like this:

Company
Id
Name
Description

Applications
Id
Name
Description

Company_Applications
Id
Company_id
Application_id
Coordinator
Feb 17, 2008 at 3:35 AM
DbEntry compose the two table name as medi-table name. And the less one will be the first table name.
So the table name will be Application_Company.
It you not sure what the table name is. Create it by using following code:
DbEntry.Context.Create_ManyToManyMediTable(typeof(Company), typeof(Application));