I've got table
Tourists
Tourist_ID
2.Name
Extra_Charges
- Extra_Charge_ID
- Description
Toutist_Extra_Charges
- Tourist_Extra_Charge_ID - primary key
- Tourist_ID - foreign key
- Extra_Charge_ID - foreign key
I try to make this sql query using entity framework ent
"Select Tourist.Name, Extra_Charges.Extra_Charge_Description, FROM Tourist
LEFT JOIN TOURIST_EXTRA_CHARGES on Tourist.Tourist_ID = TOURIST_EXTRA_CHARGES.Tourist_ID
LEFT Join EXTRA_CHARGES on TOURIST_EXTRA_CHARGES.Extra_Charge_ID = EXTRA_CHARGES.Extra_Charge_ID
WHERE Tourist.Tourist_ID=86
I want to get the name of the tourist with id=86(event if he doesn't have extra_charges) AND IF HE DOES HAVE EXTRA_CHARGES - THE DESCRIPTION OF THE EXTRA_CHARGE
As I'm new to entity framework I tried the following
foreach (var tourist in db2.Tourist.Include("TOURIST_EXTRA_CHARGES").Include("EXTRA_CHARGES").Where(x=>x.Tourist_ID==86))
{
lblproba.Text+="Name" + tourist.Name_kir+" Description" + tourist.TOURIST_EXTRA_CHARGES.//don't have access to extra_charges table
}
But when I type tourist.TOURIST_EXTRA_CHARGES I don't have access to extra_charges table and its Description column
EDIT:
I read that to use the entity framework mapping with many-to-manyrelationship i should delete my column TOURIST_EXTRA_CHARGE_ID and make compository primary key. But when I did that - and made new edmx model - I now can't see my Tourist_Extra_Charges table. And nomatter how many times i created the model - this table didn't occur in the model