如有下表:
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 请问怎么处理?
如果不用楼主这样的写法,换成http://www.cnblogs.com/yukaizhao/archive/2010/05/17/linq_to_sql_inner_join_outer_join.html
中的写法inner 也应该可以实现楼主的功能
teacher是不是没有起别名??