I have a class Test which has a collection of TestVersion children.
I have made a criteria on Test called "Key".
When I use GetTestByKey the list of TestVersions is not loaded correctly.
The reason is the stored procedure:
CREATE PROCEDURE dbo.mas_GetTest
@Key nvarchar(255),
@TestID uniqueidentifier
AS
IF (@TestID IS NULL AND @Key IS NULL)
RETURN -1
SELECT
[TestID],
[Key],
[TypeId],
[Name],
[TestLastModified]
FROM
dbo.[mas_Test] with (nolock)
WHERE
([TestID] = @TestID OR @TestID IS NULL)
AND ([Key] = @Key OR @Key IS NULL)
exec dbo.mas_ListTestVersionByTest @TestID
SET QUOTED_IDENTIFIER OFF
As you can see this code only loads the children when a TestID is specified.