Thursday, November 25, 2010

How to create shortcut for namespaces in your view files for ASP?

You can import namespaces at the beginning of the page and reference them directly.

<%@ Import Namespace="myapp.Controllers" %>

If you have a Product controller in myapp, you can reference this directly without writing myapp.Controllers.Product.

Friday, November 19, 2010

How to trigger event for Truncate action in MS SQL


I guess it is not possible to trigger event for Truncate,but prevent it.

From msdn:
TRUNCATE TABLE cannot activate a trigger because the operation does not log individual row deletions. We can prevent truncate action,if we create a view WITH SCHEMABINDING.

If we don't use truncate on the application level, we will be dealing with only delete command. It is easy to prevent that with Instead Of Trigger.