如何映射模型 [英] How do I map the model

查看:70
本文介绍了如何映射模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我创建了一个MVC数据库第一种方法因此我需要将我自己的模型映射到视图。



例如:



数据库第一种方法在edmx下创建了数据库表名tbl_employee。



我在名为Employee的模型中创建了一个类,现在我需要将这个Employee实体绑定到我的视图。



如何将新的类实体映射到我的视图?



  var  employe = db.tblEmployee.Select(o =& gt;  new  {o.e_id,o.e_name,o.e_address,o。 e_email,o.e_gender,o.e_phone,o.e_branch,o.e_course,o.e_batch}); 

解决方案

ScottGu&#博客 - 在现有数据库中使用EFCode First [ ^ ]

Hi All,
I have created a MVC database 1st approaches therefore i need to map my own model to the view.

For an example:

Database 1st approach created database table name tbl_employee under the edmx.

I have created a class in the model named as Employee now i need to bind this Employee entity to my view.

How do i map the new class entity to my view?

var employe= db.tblEmployee.Select(o =>  new { o.e_id, o.e_name, o.e_address, o.e_email, o.e_gender, o.e_phone, o.e_branch, o.e_course, o.e_batch });

解决方案

ScottGu's Blog - Using EF "Code First" with an Existing Database[^]


这篇关于如何映射模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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