I have the same entity setup as you described and also see the same behavior. Very odd. It's a prefetch path fetch which gives this error. Looking into it.
I get a DIFFERENT query:
SELECT
[InheritanceTwo].[dbo].[Project].[Id] AS [F0],
[InheritanceTwo].[dbo].[Project].[Title] AS [F1],
[InheritanceTwo].[dbo].[Project].[ProjectType] AS [F2],
[InheritanceTwo].[dbo].[Project].[ParentProjectId] AS [F3]
FROM [InheritanceTwo].[dbo].[Project]
WHERE
( (( [InheritanceTwo].[dbo].[Project].[ParentProjectId] = @ParentProjectId1))
AND ( [InheritanceTwo].[dbo].[Project].[ProjectType] = @ProjectType2))
parameters:
Parameter: @ParentProjectId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.
Parameter: @ProjectType2 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.
Code:
ProjectEntity p = ProjectManager.FetchWithSubProjectCollection(2);
Table SQL:
CREATE TABLE [Project] (
[Id] [int] NOT NULL ,
[Title] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[ProjectType] [int] NOT NULL ,
[ParentProjectId] [int] NULL ,
CONSTRAINT [PK_Project] PRIMARY KEY CLUSTERED
(
[Id]
) ON [PRIMARY] ,
CONSTRAINT [FK_Project_Project] FOREIGN KEY
(
[ParentProjectId]
) REFERENCES [Project] (
[Id]
)
) ON [PRIMARY]
GO
Created 2 entities: Project (disc: 1) and SubProject. (disc 2)
Created 3 instances:
Id Title ProjectType ParentProjectId
----------- -------------------------------------------------- ----------- ---------------
2 ParentProject 1 NULL
8 SubProject1 2 2
9 SubProject2 2 2
(edit) this code also works fine:
ProjectEntity p = new ProjectEntity(2);
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
Debug.Assert(adapter.FetchEntity(p));
adapter.FetchEntityCollection(p.SubProjectCollection, p.GetRelationInfoSubProjectCollection());
}
Debug.Assert(p.SubProjectCollection.Count == 2);
(latest build of v2.0 runtime libs)