Sql – How to generate private LINQ to SQL classes

linqlinq-to-sql

I'm trying to figure out how to make the generated LINQ to SQL classes be marked private instead of public, so that it is not visible outside the assembly. There doesn't seem to be a way to do this in the Visual Studio O/R designer or the SqlMetal tool, unless I'm missing something. Is there a way to do this?

I'm asking because I'm using LINQ to SQL internally as a data access layer in a business logic assembly. I am exposing to clients a separate set of custom entity classes, and I don't want the LINQ to SQL classes to be exposed at all.

Best Answer

It is possible, in the Visual Studio Designer select the class and in properties you can change Access to Internal.

alt text http://img410.imageshack.us/img410/970/l2svs2008access.png

The same principles apply for the DataContext itself (just click in the "white area" of the designer) and change under Properties.