我正在尝试使用Entity Framework构建一个分层收集 – 请参阅下面的查询 – 给定公司中的每个成员都有一个父成员 – 但是当尝试执行此操作时,我会收到以下异常:
System.NotSupportedException: The type
‘Member’ appears in two structurally
incompatible initializations within a
single LINQ to Entities query. A type
can be initialized in two places in
the same query,but only if the same
properties are set in both places and
those properties are set in the same
order.
如果我删除ParentMember分配它的工作 – 任何关于发生什么的想法?
return from c in _Entities.Company where c.Deleted == false select new Member() { Name = c.Name,ParentMember = new Member() { Name = c.ParentMember.Name } };