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 works 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's 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's going on here?
I even tried calling ToArray()
before foreach
, but that did not help.
EDIT:
If I change the query to:
var children = DataContext.Entities.Nodes
.Where(n => n.Parent.Name == node.Key)
.ToArray()
.OrderBy(n => n.SortOrder);
It works... why?
EDIT 2: BTW the Parent
navigator points to the same table, so each Node
can have {0..1} parent Node
.