Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EF选择内部选择_C#_Entity Framework_Linq To Entities - Fatal编程技术网

C# EF选择内部选择

C# EF选择内部选择,c#,entity-framework,linq-to-entities,C#,Entity Framework,Linq To Entities,我有以下EF表达式: var complexes = db.ResidentialComplexes.AsNoTracking() .Where(rc => rc.MasterEntity == entity) .Select(rc => new CustomComplexObj() { ComplexId = rc.ComplexId,

我有以下EF表达式:

var complexes = db.ResidentialComplexes.AsNoTracking()
                .Where(rc => rc.MasterEntity == entity)
                .Select(rc => new CustomComplexObj()
                {
                    ComplexId = rc.ComplexId,
                    Name = rc.Name,
                    Region = rc.Region,

                    Properties = rc.CurrentProperties.Select(p=> new CustomPropertyObj(){
                         Name = p.Name,
                         PropertyId = p.PropertyId
                    }).ToList()

                }).ToList();
设置时,我收到一个错误:

Properties = rc.CurrentProperties.Select(p=> new CustomPropertyObj(){
                             Name = p.Name,
                             PropertyId = p.PropertyId
                        }).ToList()
这就是错误:

LINQ to Entities无法识别方法“System.Collections.Generic.List
1[CondoTrack.Model.Poco.CustomPropertyObj]ToList[CustomPropertyObj](System.Collections.Generic.IEnumerable
1[CondoTrack.Model.Poco.CustomPropertyObj]),并且无法将此方法转换为存储表达式。


有关如何获得所需结果的任何线索?

删除
列表()
,并将
属性更改为
IEnumerable
,而不是
列表。正如错误中所述,
ToList
不受Linq to实体的支持。

太好了!!非常感谢安德烈!只是等着接受答案。