We're using Linq-To-SQL in one of our projects, and I like to modify the template the code generate uses to add some Code Analysis suppression attributes. Anyone know how I can do this?
+4
A:
Have a look here (by Damien Guard), it provides a good rundown on using T4 Templates for this purpose.
Also, looks like he's since posted the whole thing on CodePlex: LINQ to SQL templates for T4
Nick Craver
2010-02-08 13:51:29
A:
You can't modify it. It's compiled into the SQLMetal.exe tool. What you can do is use a T4 template as Nick states.
Steven
2010-02-08 13:53:06
+2
A:
Many of the Linq-To-SQL classes are implemented as partial classes. If you implement your own partial class (http://msdn.microsoft.com/en-us/library/wa80x488%28VS.80%29.aspx) you could added the attributes to it. By using the partial class you avoid the risk of your attributes being removed the next time the Ling-To-SQL classes are generated.
Michael Edwards
2010-02-08 13:56:12