I cant seem to finish my linq statement with the correct select. So far I have the following, but the problem is it results in a 'Select' of only the CategoryTypes's, when I want a select on everything:
var qwe = dc.LeadTypes
.Include("DataTypes")
.Include("DataTypes.CategoryTypes")
.Where<LeadType>(x => x.Disabled == false)
.SelectMany(x => x.DataTypes)
.Where(x => x.Disabled == false)
.SelectMany(x => x.CategoryTypes)
.Where(x => x.Disabled == false)
.ToList();
Resulting SQL
SELECT
[Extent3].[CategoryTypeID] AS [CategoryTypeID],
[Extent3].[Name] AS [Name],
[Extent3].[DataTypeID] AS [DataTypeID],
[Extent3].[Disabled] AS [Disabled]
FROM [LeadLookup].[LeadType] AS [Extent1]
INNER JOIN [LeadLookup].[DataType] AS [Extent2] ON [Extent1].[LeadTypeID] = [Extent2]. [LeadTypeID]
INNER JOIN [LeadLookup].[CategoryType] AS [Extent3] ON [Extent2].[DataTypeID] = [Extent3].[DataTypeID]
WHERE (0 = [Extent1].[Disabled]) AND (0 = [Extent2].[Disabled]) AND (0 = [Extent3]. [Disabled])
The reason I am doing this is because I have a disabled column on each of the three tables and I do not want to return those rows.
Thanks