我是实体框架的新手,我有以下数据库结构。
我正在尝试获取相关的测试模板。
到目前为止我所尝试的内容如下:select (select sum(item) from table where level = 1) - (select sum(item) from table where level = 2) from dual
Q1:为什么我无法获得var val = context.TeamTest
.Where(x => x.Tests_Id == 47)
.Select(x => x.Team.Profile.ProfileSelections);
我也尝试过这种方式。
.Select(x => x.Team.Profile.ProfileSelections.Templates);
Q2:从以上两种方法获取记录的最佳方式是什么?
Q3 一般来说获取记录的最佳方法是什么? (直接使用上下文对象,如我提到1或使用2中提到的连接查询?
答案 0 :(得分:1)
Q1:您应该启用LazyLoading:
context.Configuration.LazyLoadingEnabled = true;
并检查Team,Profile,ProfileSelections和Templates属性是否具有虚拟注释。
Q2,Q3:第一种方法非常简单明了,但第二种方法更有效。
答案 1 :(得分:1)
Q1如果映射正确Info
LikeView likeView = (LikeView) findViewById(R.id.like_view); (LikeView)
likeView.setObjectId("https://www.facebook.com/tomatojuice"); (SetObjectID)
likeView.setForegroundColor(-256); (setForegroundColor)
对我而言,这是最好的方法,因为只获取和设置您需要的数据