asp.net的SqlDataSource VS在code这样做的背后 [英] asp.net sqldatasource vs doing it in code behind

查看:170
本文介绍了asp.net的SqlDataSource VS在code这样做的背后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这很可能将归结为一个哲学问题比什么都重要,但有真正的℃之间使用任何重大的区别; ASP:;在ASPX SqlDataSource的&GT文件与做所有的工作在后面的code?

This is probably going to boil down to a philosophical question more than anything, but is there really any major difference between using the <asp:sqldatasource> in the aspx file versus doing all of the work in the code behind?

如果这样它们是什么,为什么?我知道我有我的preferences,但我只是好奇别人怎么想。

If so what are they and why? I know I have my preferences, but I am just curious what others think.

编辑:

我故意没把我的preference中是把尽可能多的在后面的code,甚至DAO。我很好奇别人怎么想,因为我将不得不更新了一堆code具有的SqlDataSource来电遍布apsx文件。

I purposely didn't put my preference in which is to put as much as possible in the code behind or even DAO. I was curious what others thought since I am going to have to update a bunch of code that has sqldatasource calls all over of the apsx files.

谢谢大家谁回答。我AP preciate输入。

Thank you everyone who responded. I appreciate your input.

推荐答案

在asp.net页面中嵌入你的SqlDataSource与从而降低了可测试性和灵活性,数据访问层耦合的presentation层。我强烈建议转移到自己的类的数据连接和创建的数据访问层,它的网页背后的code然后可以借鉴。

Embedding your SQLDataSource within the asp.net page is coupling your presentation layer with your data access layer resulting in reduced testability and flexibility. I strongly suggest moving your data connections to their own classes and created a data access layer that your code behind pages could then draw from.

在理想情况下,你会进一步单独进入这个N层解决方案。 链接

Ideally you'd seperate this even further into an N-Tier solution. Link

这篇关于asp.net的SqlDataSource VS在code这样做的背后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆