I have this LINQ query:
var children = DataContext.Entities.Nodes .Where(n => n.Parent.Name == node.Key) .OrderBy(n => n.SortOrder); foreach (var child in children) var childNode = CreateNode(child);
When using SQL Server, everything is working fine. However, when using SqlCe, I get the following error:
[SqlCeException (0x80004005): Not implemented] System.Data.SqlServerCe.SqlCeDataReader.ProcessResults(Int32 hr) +125 System.Data.SqlServerCe.SqlCeDataReader.IsEndOfRowset(Int32 hr) +131 System.Data.SqlServerCe.SqlCeDataReader.Move(DIRECTION direction) +376 System.Data.SqlServerCe.SqlCeDataReader.Read() +95 System.Data.Common.Internal.Materialization.Shaper`1.StoreRead() +44 [EntityCommandExecutionException: An error occurred while reading from the store provider data reader. See the inner exception for details.] System.Data.Common.Internal.Materialization.Shaper`1.StoreRead() +130 System.Data.Common.Internal.Materialization.SimpleEnumerator.MoveNext() +46
Any idea what is going on here?
I even tried calling ToArray() before foreach , but that didn't help.
EDIT:
If I changed the request to:
var children = DataContext.Entities.Nodes .Where(n => n.Parent.Name == node.Key) .ToArray() .OrderBy(n => n.SortOrder);
It works ... why?
EDIT 2:. By the way, the Parent navigator points to the same table, so each Node can have a {0..1} parent Node .
source share