locked
C# 2010 working with database RRS feed

  • Question

  • In a  C# 2010 .net application, I need to write some linq to sql statments for sql server 2008 database that completes the following tasks:

    1. Delete one row from a table where the record I would be deleting is the key to the table called main.

    2. Delete records from an associated table (called sub) that has the key to the main table as one of its columns. This table called sub has no foreign key constraints setup as a requirement to the table called main. In the table called sub there can be from 1 to 500 occurences of the reference to the table called main.

    3. How  should I setup these two deletes? Would this be separate linqs statements? would I need two separate  DeleteOnSubmit statements? Would I wrap the two delete statements into one transaction so that if there is a problem, I can rollback the changes?

    Can you tell me and/or point me to a reference on how to complete this task?


    Tuesday, June 19, 2012 6:21 PM

Answers

  • Hello wendy elizabeth,

    In a  C# 2010 .net application, I need to write some linq to sql statments for sql server 2008 database that completes the following tasks:

    1. Delete one row from a table where the record I would be deleting is the key to the table called main.

    2. Delete records from an associated table (called sub) that has the key to the main table as one of its columns. This table called sub has no foreign key constraints setup as a requirement to the table called main. In the table called sub there can be from 1 to 500 occurences of the reference to the table called main.

    3. How  should I setup these two deletes? Would this be separate linqs statements? would I need two separate  DeleteOnSubmit statements? Would I wrap the two delete statements into one transaction so that if there is a problem, I can rollback the changes?

    Can you tell me and/or point me to a reference on how to complete this task?

    for linq to sql , i wrote some months ago this sample , http://code.msdn.microsoft.com/LinqToSqlExample-415f51e6

    Regards.


    Tuesday, June 19, 2012 6:56 PM