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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.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
Entity framework 在何处放置实体框架存储库类中使用的数据传输对象_Entity Framework_Repository_Dto - Fatal编程技术网

Entity framework 在何处放置实体框架存储库类中使用的数据传输对象

Entity framework 在何处放置实体框架存储库类中使用的数据传输对象,entity-framework,repository,dto,Entity Framework,Repository,Dto,由于实体框架的技术限制,我必须在一个额外的类(数据传输对象)中返回数据,而不是使用模块类返回数据 from m in context.Modules.Where(x => x.ParentId == null) join child in context.Modules on m.Id equals child.ParentId into groupJoin select new ModuleDTO { m.Id, Has

由于实体框架的技术限制,我必须在一个额外的类(数据传输对象)中返回数据,而不是使用模块类返回数据

from m in context.Modules.Where(x => x.ParentId == null)
          join child in context.Modules on m.Id equals child.ParentId
              into groupJoin
          select new ModuleDTO { m.Id, HasChildren = groupJoin.Any() }
ModuleTo不是我的业务对象。它在我的ModuleRepository中使用


我应该把这个只保存getter/setter(当然没有逻辑)的DTO对象放在哪里?

被模块化为只暴露于存储库、上层或多层?@LadislavMrnka DTO被返回到我的Asp.Net Mvc控制器,在那里它被映射到一个viewmodel。因此,只有我的ModuleRepository和我的ModuleController知道ModuleTo。为什么不将DTO放在与存储库相同的程序集中,而您的控制器必须引用它?@LadislavMrnka我尝试过一次,但遇到了一些无法解决的问题。现在我又试了一次,是的,谢谢,它很管用。