To linq To SQL or not... that is the question? - linq-to-sql

Our team is now beginning to look at jumping from 2.0 to 3.5 and have been reviewing all the new stuff....
So, with the whole Linq to SQL not being heavily improved in the future should we ignore it completely?
It seems that it may fit of our needs very well BUT I imagine so could entity framework even if it may add more complexity.
So avoid Linq To SQL like to plague and go with entity framework instead or jump on in, Linq To SQL will be just fine in 4.0 and future releases even without improvements?

Everything I've read seems to suggest that Linq2SQL will still be around for a while. I would, if I were you, just pick the one that best suits the problem you're trying to solve. I might be a little biased toward using the Entity Framework because it's more abstract and might be a good capability for you and your team to have, and because Visual Studio 2008 has a designer for it.
I just don't think it's that big a deal for a few years. Just pick the one you like the best for now.
Update: lest there be any confusion - using the EF doesn't mean giving up Linq. Linq can already be used with the EF.

Very similiar to my question # Switching to LINQ
Might offer further insight/opinions.
Personally, I am going to start focusing on EF since everything I see coming from MS is that LINQ is just the beginning and a big part of the foundation of EF.

I would pick LINQ only because it is simpler, and when you finish your application, and are looking at optimizing, and refactoring, then you can try Entities, and see if you have any performance improvements, or if it makes the code better.
I tend to start with the simpler, faster-to-develop, method, to get the functionality finished, then I refactor, then optimize.

I'd have picked EF in any case. I never liked the idea that LINQ to SQL mapped directly to the database structure. I greatly preferred the idea of EF, where I can decide what entities I want to present to users, and then map them to the database tables as appropriate.

LINQ to SQL and Entity framework are not comets passing by. They are real coding revolutions !
We can now query databases in 1 hour where it took us 1 day before !
Do not hesitate to jump. If .Net 4.0 does not suport LINQ to SQL or Entity framework, just stick to 3.5 !
:o)
All the best, Sylvain.

If LINQ to SQL fits your needs, then go with it. Its really a very powerful RAD tool.
EF will give you more flexibility, but also perhaps unnecessary complexity.
Its a shame LINQ to SQL isn't moving forward anymore, but I'd stick to it until EF really matures and allows equal RAD development, unless of course, you need EF features now.

I would say that it depends. Everyone else so far has put things very well.
Use LINQ-to-SQL if you don't mind the fact that your eventual object model is going to very closely mirror your database. There's not a lot you can do with or to a LINQ-to-SQL model if you find that you want to model things differently.
Use EF if you want to potentially use the same framework to point to multiple types of data, or if you'd like to abstract your database model more than is possible in LINQ-to-SQL.
I don't have any data on, say, performance differences between the two models, unfortunately.
I wouldn't say the fact that MS isn't doing a lot of active development on LINQ-to-SQL should necessarily scare you away. Its a very good, very, very basic object mapping solution.

Related

What are the advantages of EF4 or LINQ to SQL?

What are the advantages of EF4 and under what circumstances is it preferred over LINQ to SQL?
LINQ to SQL will have no more future development. So EF is the way to go in the future.
Entity Framework vs LINQ to SQL (this should explain what you want to know)
Well, two of the major differences are:
1) EF can target multiple database engines, including Oracle and MySQL. Not just MS SQL Server.
2) You can do so-called "code first" schema development. Basically you create your object model, and along with some hints, EF will generate the schema for you.
Seems to me that Linq to Sql is great for rapid prototyping and simple CRUD scenarios. Anything more advanced or enterprisey would use EF4. (Or at least that's what MS would like us to believe :) I've had good luck with Linq to SQL in production, for what it's worth.
EF4 basically adds a whole bunch of OO-ness to the mapping that isn't present in LINQ-to-SQL, such as rich object inheritance models. My own take on it is that none of that is necessary for good design, and I have yet to come across a single scenario in my own work that warrants the added complexity EF4 brings to the table.
Having said that, Microsoft has deprecated LINQ-to-SQL and will not continue developing it, so it will eventually fall behind EF4 in capability and efficiency (if it hasn't already). So the pragmatic choice is simple: go EF4.
After trying both and spending over one weeks porting a project from linq to sql, I can say that I really prefer Linq to SQL. The main reason for this is that EF is more restrictive on what functions you can use in LINQ queries. In EF I had to cast my linq expressions to a list to be able to manipulate them any further. Sorry for not being able to remember any example, it's been a few months since I did this...
One of the really big plus sides for EF, is the ease of use in connection with WCF Data Services. Very handy if you are developing a web site that should have an RESTful API.
Also, even though Linq to SQL is quite mature, it is indeed a dying technology. It won't get any significant updates, that makes it harder to commit to Linq To SQL for a new project.

DBLinq for a production system?

We're working on an ASP.NET web application with C# code behind. The database is MySQL 5.1 using InnoDB. The data access layer uses ADO.NET to call stored procedures and then builds various data structures out of the result sets (no object mapping). This works fine, but it is a little verbose.
Not surprisingly, we made some mistakes when designing the first version of our data model, but the experience has made us smarter and we decided to refactor the data model. We don't have to change our data access layer, but we are considering our options for that as well.
It's been difficult for us to ignore the popularity of ORM tools these days; we feel like we are way behind or something for not being familiar with them. Not only that, but we have already designed an object model that nicely describes our data model. The main ORM tools we would consider are NHibernate, ADO.NET Entity Framework, and LINQ to SQL. We would prefer LINQ to SQL because we have read (on S.O.) that it is more light weight than full ORM tools.
We think one drawback to using an ORM tool is the learning curve, but we can already see how using LINQ could reduce the amount of code we will have to write, which could save us time in the long run. However, we are using MySQL, not SQL Server.
So my question is, would DBLinq work well enough for a production system? Or, is LINQ to SQL a compeling enough reason for us to make the move to SQL Server 2008? Incedentally, I'd prefer to use SQL Server over MySQL, but cost is the obvious drawback. After 3 years on BizSpark, we'd be on the hook for $6K. Or, should we consider other ORM tools instead? Or, should we just ignore the hype and not use an ORM tool, but maybe take advantage of LINQ to DataSet?
I searched S.O. for info on DBLinq, but only found 17 questions with the DBLinq tag, so it doesn't appear to be popular.
EDIT
Looks at though dotConnect for MySQL has support for LINQ, so that's another option.
Can anyone speak to how well that driver works for writing LINQ queries?
Check bl-toolkit. It's free, very fast and has great LINQ support. Newest addition are T4 templates for generating your data model from database.

Is it worth a try LINQ to SQL as a beginner to an ORM?

Thus far used sql server stored procedures for all my web applications... Now thought of moving to an ORM... I would like to ask SO users about LINQ to SQL
Is Linq to sql worth a try as a beginner to an ORM?
or should i look for some others... Any suggestion...
EDIT:
I have a sql server 2005 database with all tables....
How to use this db with Linq to sql?
Coming from using ADO.NET table adapters, LINQ was a revelation. A breath of fresh air. The veil was lifted. A new day dawned. And so on and such forth.
Start with Scott Gu's series here and check all his other blogs on the subject.
I envy you your impending joy.
Skip it. Second grade little ORM missing all the interesting features (and don't get me even started with EntityFramework - crap in v1, barely usable in v2).
I suggest getting ahold of NHibernate.
Even though I, unfortunately, don't do much Windows/.NET development anymore, I still think that C#/.NET is the best programming environment around and that Linq is a great ORM. If you're on the .NET/C# platform, use it. There's good documentation, a large community of users to help you, and very solid implementations.
While Microsoft SQL Server doesn't get a lot of buzz, it is a very worthy database to be the platform underlying linq.
If you're just starting, then I recommend you ignore LINQ to SQL. Microsoft will be placing all of their development efforts behind Entity Framework, which is more powerful and general than LINQ to SQL.
Coming from a similar situation I found linq-to-sql worked really well. We previously used a repository pattern and managed to follow it pretty closely with linq to sql in about half the time. Linq-to-Sql will also allow you to write and use regular store procedures.
For a beginner I found the linq-to-sql sections of the Nerd Dinner tutorial a good starting point.
Personally, I think that L2S is a great choice for a ORM beginner because it's really easy to use, but still gives you plenty of power. IMO, if you are doing new SQL Server work, L2S is the best and easiest ORM available. It's not perfect, but neither is anything else out there.
Also, PLINQO adds a lot of the missing features to L2S that bring it more in line with EF, while maintaining the simplicity and speed of L2S.

linq to entities vs fluent nhibernate vs linq to sql (Help)

I have to build a website for a news channel..
Please help me decide which technology to use for data operations?
1) Linq to Entities
2) Linq to SQL
3) Fluent NHibernate
4) ADO.Net
Website will be based on ASP.Net MVC and C#.
Main Issues:
1) Should be easy to maintain and scale.
2) Good Performance
Please express your view with an example if possible..
Thanks
Chitresh
Pro and cons:
LINQ To Entities
Allows you to add another layer of abstraction (entity) instead of mapping directly to tables (like in LINQ to SQL). Support multiple data providers (not just SQL Server). Require a bit more learning time than LINQ to SQL. Provide unit of work concept. Medium to High learning curve.
LINQ to SQL
Allows you to easily map your tables, stored procs, etc. Provide unit of work concept. Only work on SQL Server backend. Easy to implement, but require dbml rebuild if db schema changes (1 way synchronization from db to object), so a bit harder to maintain. Low - Medium learning curve. Performance, ... I think Stack Overflow is using LINQ to SQL. How do you think it performs? Have unit of work concept.
Fluent NHibernate
Can't comment ... know nothing about it. If it is anything like NHibernate, should be quite flexible. Probably high learning curve. Someone correct me on this...
ADO.NET (Not talking about Named DataSet here...)
Should be the fastest (no abstraction). Flexible, bend it anyway you want. Low learning curve. Very basic, do everything yourself approach. Most of the time I go this route for simple project. Can lower productivity. You can augment it with code generation to gain some productivity.
Your other options... Subsonic perhaps.
NHibernate(Fluent NHibernate)
Fluent NHibernate is a component to help you map your Entities so that NHibernate knows where it's gonna put your data from the database. If you never used NHibernate it can be a little difficult to know how to map and handle a NHibernateSession but there are lots of information here on stackoverflow and other places like S#arp for an exemple of session handling and Summer of NHibernate to get some lessons in mapping.
I would go with Linq to Entities or NHibernate (actually, I would go with NHibernate, but that is one I'm the most familiar with) -- AND ADO.Net (but just a little bit).
Start by doing everything you can with NHibernate/Entities. Once it is up and going you will find it remarkably productive. But there are situations where you will need a bit more performance (do you have a good profiling tool?). For those cases, code them in straight Ado.Net (that should make up less than 10% of your database calls). With NHibernate, you can use the NHibernate session to get your connection object for you as well.

linq2sql disadvantages

I am hearing a lot of rumours that Linq2Sql is not going to be supported any more in the next version of .net. I like Linq2Sql a lot and find it very easy / lightweight to work with. I can understand some of the problems people have had with it (ppl used to nhibernate...) but used correctly I think most problems can be solved. I currently use it in all my projects now and I would hate to see that it isn't going to be supported any more.
So list the disadvantes you see with Linq2Sql
If there were another version of Linq to SQL, here's my feature wishlist:
Things I actually wanted whilst building my last Linq-to-SQL project (and had to work around manually in most cases)
Many-many associations
Better visual designer (including a "refresh table" feature)
Control over cascade delete/update/SET NULL that doesn't involve hacking the XML
Specific mappings for culture/string comparisons into SQL COLLATE statements (e.g. specifying whether passwords should be case sensitive or not, rather than relying on the default collation of the underlying database.)
Things I might want but haven't actually needed yet:
Support for ordered collections (persisting lists to the DB so they are automatically retrieved in the same order they were persisted)
LINQ to SQL can certainly be fixed. But so long as the ADO.NET team is in charge of it, I seriously doubt it will be.
If it gets open sourced I think it will be a force to be reckoned with. But as it stands, it is a dying technology.
One of the biggest disadvantages I see in L2S is that it is a really hassle to use it in disconnected scenarios; send off a serialized version of an entity to another and try to "merge"/update it when you get it back and you will see it's shortcomings. If the .Attach() functionality had worked for such scenarioes, L2S would have been quite nice.
--larsw
First and foremost, people are losing interest in it since it will not be developed any further, and Entity Framework will go forward instead.
LinqToSQl works and is pleasant to use, but EF will overtake it sooner or later.
The ORM purists would prefer if it was easier to set up LINQ to Sql to use an object model that is external to the LINQ to SQL data layer. This can be done in Linq to SQl, but it's a manual process that's far from the default configuration.