views:

281

answers:

4

I can't find a template for a linq to sql class in .net 2.0 project, based on what i know you can work with linq in .NET 2.0 as long as you have 3.5 in your development machine and ship system.core.dll with your application?

so based on that how can I add a Linq to Sql model to my project when "Linq to Sql Classes" template is missing from the add new item window?

Edit:

Just to clear things up, This is a server application and the server will have .net 3.5 SP1. the only issues is that we can not upgrade the project to .net 3.5 at the moment.

+1  A: 

If you ship System.Core with your application, it won't pick up future security fixes and won't have the optimized build installed (MS internally uses and profiling NGEN for distributed framework libraries). Either require .NET 3.5, avoid using Linq, or implement your own extensions for a custom Linq provider.

280Z28
A: 

Try adding a reference to System.Core

http://iformattable.blogspot.com/2008/05/using-linq-from-net-20.html

David Stratton
I like 280Z28's answer better than my own. Good point.
David Stratton
+1  A: 

The approach you are taking is dangerous and will almost certainly lead to errors on your deployment machine.

The 3.5 framework, and specifically System.Core.dll, rely on the CLR being at least 2.0 SP1. There are several bugs in CLR 2.0 that are exposed by the use of the expression tree API and other code which Linq2Sql relies upon.

If you ship System.Core.dll only the clients are not guaranteed to have, and likely won't have, the CLR service pack. Hitting any of these bugs will result in hard to understand failures in your application.

You may get lucky for awhile but this is an untested and unsupported scenario.

I highly advise you to not do this

JaredPar
A: 

I figured it out, All you have to do is add a new text file to the project, but change the extension from .txt to .dbml and it'll automatically be picked up by visual studio. it will even generate all the code behind for you.

Keivan