ASP.NET MVC 论坛应用程序
我需要为朋友的网站编写一个论坛应用程序。我想用 C# 3.0 针对 ASP.NET MVC 框架和 SQL Server 数据库编写它。
所以,我有两个问题:
- 我应该使用 Linq to SQL 还是实体框架作为数据库抽象?
- 我应该使用 ASP.NET Membership API 还是添加 Users 表并自己实现?
谢谢。
I need to write a forum application for a friend's web site. I want to write it in C# 3.0 against the ASP.NET MVC framework, with SQL Server database.
So, I've two questions:
- Should I use Linq to SQL or the Entity Framework as a database abstraction?
- Should I use the ASP.NET Membership API or add Users table and implement it myself?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
原因:
实体框架与 LINQ to SQL
Reason:
Entity Framework vs LINQ to SQL
1)两者都怎么样?只需创建一个抽象,您就可以使用其中一个。我的建议是使用存储库模式。
2) 会员提供商有其优点和缺点。对于某些项目来说,它对于我的需求来说太复杂了。然而,如果您需要在短时间内运行某些东西,那么这是很好的选择。
1) How about both? Just create an abstraction and you could just use either. My recommendation is to use the repository pattern.
2) The membership provider has its strengths and weaknesses. For some projects, it was far too complex for my needs. However, it is great if you need to get something running in a short amount of time.
我不会回答第一个问题,因为我是 nhibernate 的粉丝
对于第二个问题,添加用户表并自己实现会员资格,我认为您至少无法以正确的方式做到这一点(很多人试图制作自己的会员资格 API,但他们搞砸了!)
I won't answer the first question since i'm a fan of nhibernate
for the second question adding a users table and implement membership yourself i don't think you will be able to do it at least the right way (lot of people tried to make their own membership api but they messed up !)
1)完全取决于事情将变得多么复杂。如果您想要一个或多或少以 1:1 方式镜像您的表的快速 DAL,请选择 L2S(或者 SubSonic,如果您想要更成熟和受支持的东西)。如果您想要更多的 n 层类型的东西,其中您的表和域模型完全不同,请选择像实体框架这样的 OR/M(或者 NHibernate,如果您想要在各个方面都更好的东西)
2) ASP.net 成员资格极其复杂,其中有些部分的设计相当糟糕。然而,这取决于你对这些事情有多少经验。如果您足够了解如何采取措施避免会话固定攻击,请自行实施,因为它很可能比罐装解决方案更好。如果您不知道那是什么,请花点时间学习默认的。
1) Totally depends on how complex things are going to get. If you want a quick DAL that more or less mirrors your tables in a 1:1 fashion, go for L2S (or SubSonic if you want something more mature and supported). If you are going for more of an n-tier type thing where your tables and domain model are completely different, go for an OR/M like Entity Framework (or NHibernate if you want something that is pretty much better in every way)
2) ASP.net Membership is extremely complex, and there are bits of it that are fairly poorly engineered. However, it depends on how much experience you have with these things. If you enough to know how to take steps to avoid session fixation attacks, just roll your own because chances are it will be better then the canned solution. If you have no idea what that is, take the time to learn the default one.
需要考虑的是,SubSonic 3 是一个非常强大的数据访问生成工具。据我了解,它基本上将 Linq to Sql 包装在一些非常有用的包装器中,并使 Linq 的使用更加直观。使用 SubSonic 时,您可以立即构建一个非常强大的应用程序。但有一个小问题,如果您使用共享主机(例如 GoDaddy),您将遇到中等信任问题。在这种情况下,您始终可以回退到 Linq To Sql,而无需对代码库进行大量更改。
至于Aspnet_Membership。就其提供的工具数量而言,我建议使用它。
祝你好运,希望这会有所帮助。
Something to think about, SubSonic 3 is a pretty powerful data access generation tool. From what I understand, it basically wraps Linq to Sql inside of some very useful wrappers and makes using Linq a little more intutive. You can have a pretty powerful application built up in no time flat when using SubSonic. One little issue though, if you're using a shared hosting (say GoDaddy) you'll run into a medium trust issue. In that case you can always fall back to Linq To Sql without making many changes to your code base.
As for Aspnet_Membership. Just for the amount of tools it provides, I'd reccomend using it.
Good luck, and hope this helps.