August 2011 - Posts

Emitting Exceptions from LINQ to SQL classes in ASP.NET MVC Validation Summary
18 August 11 11:36 PM | bipinjoshi

Recently while developing a sample application in ASP.NET MVC, I came across a peculiar situation. There was a LINQ to SQL class with several extensibility methods defined (OnXXXXChanging kind of methods where XXXX is the name of a property). The methods were performing some validation checks and in case of any violation were throwing exceptions. The LINQ to SQL class was working fine. However, at some places I wanted to display the validation errors (thrown by the class as exceptions) on the ASP.NET MVC views. That is where the problem began. No matter what exception you throw in the class the Validation Summary never displays the error message.

http://www.bipinjoshi.net/articles/e90a06d2-3c4e-4abd-9143-88f85bd49629.aspx

 

Filed under: ,
Generating Code Using Text Template Transformation Toolkit (T4)
10 August 11 11:37 PM | bipinjoshi

Many times developers come across situations where they need to write similar code over and over again. Automating the generation of such boilerplate code not only reduces the time spent but also reduces the chances of errors while doing such monotonous development. To help developers achieve this goal, Visual Studio 2010 includes what is known as Text Template Transformation Toolkit (T4). T4 templates are text files that specify the structure of the code or markup to produce. T4 comes with its own set of directives and blocks, which allow you to you define the boilerplate for code generation. This article introduces you to T4 basics and familiarizes you with the various parts of a T4 template.

http://www.bipinjoshi.net/articles/3c5d9520-4c11-4a9f-a020-261b36e1f48b.aspx

Filed under: , ,
More Posts