What can map database tables like LINQ to SQL did?
A good thing in LINQ to SQL was a fast and reliable way to map database tables and convert them into clas开发者_开发知识库ses accessible from c# project. However it is no longer recommended to create projects using LINQ to SQL.
What is its substitute? What kind of tool should I use in VS 2010 today if I want to have the same functionality as I had with LINQ to SQL?
Why not??
Linq-to-SQL is still around in .NET 4, even with bugfixes and improvements. For small projects, it's still a very viable solution!
Yes, there won't be much further development on it - but it's still there, it still works, and for many projects, it's a perfect fit - just use it!
If you want to have something "future-proof", you'll need to look at Entity Framework v4.
See this blog post with a ton of links on EF4.
EF4 looks very promising - but remember: it's always a two-stage mapping process (while Linq-to-SQL is a straight 1:1 mapping from table to object). This might be great if you need the flexibility, but it might be a drawback since it adds a certain overhead.
If you really don't want to keep using Linq-to-SQL, you might also want to check out SubSonic which is another simple, easy-to-use, straightforward 1:1 OR-mapper
I would try out Nhibernate. I think it works great, never used EF4 so can't really compare. Nhibernate makes you manually declare all mappings, but they are super easy and quick to bust out and doesn't have some of the limitations of using LINQtoSQL generated classes. Also depends on your preference but I like having full control of the classes I generate and interfaces I implement off them. Syntax might take some time to get used to but I think it is really powerful tool.
http://nhforge.org/
Also some amazing video tutorials of how to use it can be found right here: http://www.summerofnhibernate.com/
What you may have heard is that Microsoft will be spending its development efforts on Entity Framework instead of LINQ to SQL. Entity Framework is what you should look at as a LINQ to SQL replacement.
Although EF does not require a one-to-one mapping to the database, that is the default when you generate a new EF model from the database. In that way, it will be equivalent to LINQ to SQL.
精彩评论