I can reproduce it with a query in the low level api too: (Employee is root, has as subtypes Clerk and Manager. Manager has as subtype Boardmember. 4 entities are in the DB, 2 clerks, 1 manager and 1 boardmember. ID, Name fields are inherited from Employee)
[Test]
public void DynamicListAutoTypeFilterAddTest4()
{
using(var adapter = new DataAccessAdapter())
{
var toDelete = new EntityCollection();
UnitOfWork2 uow = CreateTestBatchForSave2(ref toDelete);
try
{
uow.Commit(adapter, true);
var fields = new ResultsetFields(1);
fields.DefineField(ClerkFields.Id, 0);
var results = new DataTable();
adapter.FetchTypedList(fields, results, null);
Assert.AreEqual(2, results.Rows.Count);
}
finally
{
adapter.DeleteEntityCollection(toDelete);
}
}
}
This results in 4 rows (manager, boardmember ID's are also fetched), no filter is applied
SELECT [LPA_L2].[ClerkID] AS [Id]
FROM ( [InheritanceOne].[dbo].[Employee] [LPA_L1]
LEFT JOIN [InheritanceOne].[dbo].[Clerk] [LPA_L2]
ON [LPA_L1].[EmployeeID] = [LPA_L2].[ClerkID])
Using a non-pk field:
[Test]
public void DynamicListAutoTypeFilterAddTest4()
{
using(var adapter = new DataAccessAdapter())
{
var toDelete = new EntityCollection();
UnitOfWork2 uow = CreateTestBatchForSave2(ref toDelete);
try
{
uow.Commit(adapter, true);
var fields = new ResultsetFields(1);
fields.DefineField(ClerkFields.Name, 0);
var results = new DataTable();
adapter.FetchTypedList(fields, results, null);
Assert.AreEqual(2, results.Rows.Count);
}
finally
{
adapter.DeleteEntityCollection(toDelete);
}
}
}
Results in 2 rows, even though 'Name' is inherited from Employee, it applies the type filter here:
SELECT [LPA_L1].[Name]
FROM ( [InheritanceOne].[dbo].[Employee] [LPA_L1]
LEFT JOIN [InheritanceOne].[dbo].[Clerk] [LPA_L2]
ON [LPA_L1].[EmployeeID] = [LPA_L2].[ClerkID])
WHERE ((([LPA_L2].[ClerkID] IS NOT NULL)))
this is the same in QuerySpec & linq. It's indeed strange that this happens, also when I refer to the base type field in queryspec/low level API it does apply the filter while it shouldn't do that.
Looking into it.