Hello Ta Duc,
If the junction table (in your case -
EmpTag) only consists of two foreign keys, instead of adding it to the model,
OpenAccess will include two navigational properties each exposing a collection to both of the classes, for example :
In your scenario, In order to get all employees by a given list of tag ids, you can use one of the following LINQ queries :
or
where
model is the
OpenAccess EntitiesModel, and
tagsIDList is the list with tags IDs.
As an alternative, It is also possible to visualize the
EmpTag table and access it directly. In order to do that perform the following steps :
1. Remove the association between the two domain classes. (right-click on the association -> Delete )
2. Open the
Model Schema Explorer , locate the
EmpTag table and select it.
3. Press F4 to open the
Properties pane and set the
IsJoinTable property to
False
4. Simply drag the table next to the other two tables.
The result will be :
This way the
EmpTag table will be directly accessable from the
OpenAccess context.
Hope this helps.
Best Regards,
Kosta Hristov
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>