首页 新闻 会员 周边

Entity framework 查询返回比表多的数据映射不全

0
[待解决问题]

如有下表:

table teacher(id,name)

table student(id,name,teacherid)

 

通过Entity Framework生成两个类

teacher, 和 student

现在想要通过语句查询student,同时返回teachername

 

做法:

1.public class partial student{

public string teachername {get;set;}

}

 

2.查询

ent = new ent(); // 简化

ent.ExecuteStoreQuery<student>("select t1.*, t2.name as teachername from student t1 join teacher on t1.teacherid=t2.id", null);

 

返回的结果却没有teachername 请问怎么处理?

东流小溪的主页 东流小溪 | 菜鸟二级 | 园豆:202
提问于:2013-03-24 08:15
< >
分享
所有回答(2)
0

如果不用楼主这样的写法,换成http://www.cnblogs.com/yukaizhao/archive/2010/05/17/linq_to_sql_inner_join_outer_join.html

中的写法inner 也应该可以实现楼主的功能

chenping2008 | 园豆:9836 (大侠五级) | 2013-03-24 09:45
0

teacher是不是没有起别名??

平常心队长 | 园豆:1113 (小虾三级) | 2013-04-10 16:28
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册