Tag Archives: .net

Cascade Delete with Linq2SQL

Posted on 22. Dec, 2009 by naresh in .net Programming, Blog

Consider this, you have Invoice and Invioce details in 2 tables and the details are referenced by InvoiceId, What happens to Invoice Details once you delete the invoice ?, In SQL atleast you can do cascade delete and also set the value to null, but most real life programs would want to delete the details, Linq2SQL by default tries to set a null value which in most cases fails, and there is no visual way to set this the only way to do this is to do some manual xml editing.
Right click and open the .dbml file with the XML Editor and then navigate to the table for which you want to do this, then look for the relation which references the parent table

<association Name="...." Member="...." ThisKey="...." OtherKey="...." Type="...." IsForeignKey="true" />

Now add DeleteOnNull=”true” to this association so this behaves as expected

<association Name="...." Member="...." ThisKey="...." OtherKey="...." Type="...." IsForeignKey="true" DeleteOnNull="true" />

Tags: ,

My latest Work on WPF

Posted on 02. Jan, 2009 by naresh in .net Programming, Personal

WPF has been here for quite a while now and i done some basic projects on wpf, but for the last two months i had the opportunity to completely work on WPF, not just WPF but also used Linq2SQL as the base for the complete application, wet my hands with ADO.net Entity Model and lot of work in Expression Blend,
The software was for KPCC and it an complete automation and information management system for them, I will not reveal much more, but a few screens which are not part of the NDA have been posted here,
KPCC
KPCC
KPCC

Tags: , ,