如何填充包含实体框架的另一个类列表的类的proprty? [英] how fill a proprty of a class that contain a list of another class with entity framework?

查看:77
本文介绍了如何填充包含实体框架的另一个类列表的类的proprty?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

i希望用实体框架从数据库中读取一些数据。

< img src =http://i.stack.imgur.com/AhRq6 .png>

这张图片是我的实体框架类。我有一些类与我的实体框架类相称,用于在函数之间传递数据。

< img src =http://i.stack.imgur.com/FGuR3.png>




< img src =http://i.stack.imgur.com/s5e1Y.png>




现在我想要全部阅读来自tblCenterShop的行并用它们填充CenterShop类。

我的问题是CenterShop类包含centerShopImage(图像)列表。 pelase帮助我填写CenterShop类的图像?

我的功能如下:

hello
i want to read some data from database with entity framework.
<img src="http://i.stack.imgur.com/AhRq6.png">
this picture is my entity framework classes. i have some classes that they are commensurate with my entity framework classes for transfer data between functions.
<img src="http://i.stack.imgur.com/FGuR3.png">


<img src="http://i.stack.imgur.com/s5e1Y.png">


now i want to read all rows from tblCenterShop and fill CenterShop classes with them.
my problem is that CenterShop classes contain a list of centerShopImage (images). pelase help me to fill images proprty of CenterShop class?
my function is in bellow :

public IEnumerable<Model.CenterShop> GetAllCenterShops()
        {
            CenterShopSimulationEntities db = Repository.RepositoryManager.GetDB();
            return from c in db.tblCenterShop
                             select new Model.CenterShop
                             {
                                 ID = c.ID,
                                 address = c.address,
                                 category = new Model.CenterShopCat()
                                 {
                                     ID = c.tblCenterShopCat.ID,
                                     name = c.tblCenterShopCat.name
                                 },
                                 floorNumber = c.floorNumber,
                                 name = c.name,
                                 //images = ?????????,
                             };
        }



谢谢。


thanks.

推荐答案

这篇关于如何填充包含实体框架的另一个类列表的类的proprty?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆