Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use LINQ query syntax with .NET 3.0 projects?

I have a project which can only be deployed on a server running .NET 3.0. I desperately want to use LINQ to simplify some excruciatingly tedious logic. Is there a simple way to accomplish this? I'll settle for any syntax.

Thanks a lot

like image 401
Tushar S Avatar asked Jul 27 '10 21:07

Tushar S


2 Answers

Since .NET 2.0 through 3.5 all run on the CLR 2.0, all the LINQ stuff is just a bunch of libraries. If you include the DLLs that are missing on your version of the framework, it will work just fine.

As Patrick says, the key 3.5 DLLs are System.Core.dll (which provided System.Linq) and System.Data.Linq.dll (for Linq-to-SQL).

If you do this, I think you need System.dll from at least .NET 2.0SP1 I believe.

LINQBridge, as cited by Marc, works by re-implementing the functionality but only for Linq-to-Objects I believe.

Another option is to use these same DLLs (System.Core.dll and System.Data.Linq.dll) from the Mono project. They have reimplemented all of LINQ. The Linq-to-Sql stuff is perhaps a little immature but it does have the virtue of working with other databases than just MSSQL.

http://mono-project.com/Main_Page

This removes any question of the legality of distributing Microsoft DLLs with your application.

like image 178
Justin Avatar answered Oct 07 '22 13:10

Justin


A coworker used LINQBridge and had success.

like image 45
Marc Avatar answered Oct 07 '22 15:10

Marc