首页新闻找找看学习计划

linq to sql 三层架构多表连接 为什么数据不能调用?还是上面问题 执行结果就是没有反应

0
悬赏园豆:50 [待解决问题]

BLL层:
protected void Button1_Click(object sender, EventArgs e)
{
IQueryable results;
if (BLL.UserBLL.lainjie (out results))
{
GridView1.DataSource = results;
GridView1.DataBind();
}
}

DAL层:
public static IQueryable lj()
{
var results = from r in db.Score
join s in db.Student on r.Sno equals s.Sno
join c in db.Course on r.Cno equals c.Cno
select new
{
r.Sno,
r.Cno,
r.EndScore,
r.Course,
Sname = s.Sname,
Cname = c.Cname
};
return results;
}

Moodle层就不放了

UI层:
前台:
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="三表连接" />
<br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" CellPadding="3">
<FooterStyle BackColor="White" ForeColor="#000066" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
<RowStyle ForeColor="#000066" />
<SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#007DBB" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#00547E" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:schoolConnectionString %>" SelectCommand="SELECT * FROM [Student]"></asp:SqlDataSource>
注:这个可以不用看。

后台:
protected void Button1_Click(object sender, EventArgs e)
{
IQueryable results;
if (BLL.UserBLL.lainjie (out results))
{
GridView1.DataSource = results;
GridView1.DataBind();
}
}

横刀笑的主页 横刀笑 | 初学一级 | 园豆:154
提问于:2018-11-30 17:18
< >
分享
所有回答(4)
0

你可以跟踪一下数据库,看一下log

chesterdotchen | 园豆:542 (小虾三级) | 2018-11-30 17:27
0

BLL放错代码了吧

tomkluas | 园豆:208 (菜鸟二级) | 2018-11-30 17:30
0

会不会是,你dal层和bll层没有引用好

但乱红尘 | 园豆:410 (菜鸟二级) | 2018-12-05 17:27
0

result.tolist(); 只有到tolist 才是真正执行查询,前面的一大段都是在组sql

Постой! | 园豆:809 (小虾三级) | 2019-01-23 11:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册