ASP.NET项目经理Rob Howard正为存储过程跟人吵架,我基本上同意他的观点,特别是下面这句“You would never put business logic code in your presentation tier, right? Why put ad-hoc SQL in your business logic layer? ”,但好奇的是,ASP.NET 2.0提供了一个SqlDataSource控件,允许你在ASPX页面里直接设置连接字符串/SQL语句(摘自 Check Out The ASP.NET 2.0 Whidbey Features! ):
<asp<asp : sqldatasource id=”categoriesSource” runat=”server”
connectionstring=”server=localhost;database=northwind;uid=sa;pwd=”
selectcommand=”SELECT * From Categories Where [email protected]”>
<SelectParameters>
<asp : ControlParameter defaultvalue=”1″ Name=”CategoryID” ControlId=”CategoryID” PropertyName=”Text”/>
</SelectParameters>
</asp : sqldatasource>
在 presentation layer里用SQL语句?这是不是有点自相矛盾?