Accessing non-related entities in LinqToSql entity classes
- by Chris Johnson
In LinqToSql, if I want to access a non-related entity in an entity partial class, how do I do this without creating a new DataContext?
Here's the scenario:
I have the tables Client, IssueType and ClientIssueType. A Client may specify a list of IssueTypes if they do not want to use the default IssueTypes. I have the default IssueTypes in the ClientIssueType table with a ClientId of null.
In my Client partial I'd like to try to retrieve all IssueTypes, and if none are found, return all default IssueTypes. The only way I can see of accessing the IssueTypes with a null ClientId is by accessing the table through a new DataContext, which is problematic once I want to start assigning them to Issues.
Where am I going wrong?