locked
LINQ TO SQL (dbml) RRS feed

  • Question

  • Why is the class that gets generated , does not implement things in a TRY CATCH FINALLY, to catch SQL exceptions? Or do I have to wrap method calls into that ? but then what exception types are thrown?

    Thanks, and please fix the auto-gen tool, or advice.
    Sunday, May 13, 2007 1:16 PM

Answers

  • Classes generated by SQLMetal tool or Linq To SQL designer are called Entity. They are modelled to your database representing the tables of your database. So you can find properties having the name of tables' columns. If a table is related to another one you will find an EntitySet and an EntityRef variables useful to represent the relation in an object oriented way. So, I cannot see methods or properties where it could be useful adding try/catch section. Where do you would add them?

     

    On the other hand, when you instantiate a variable from xxxDataContext class and call a method such as SubmitChanges() you have to use the try/catch block in order to catch an exception such as ConcurrencyConflictException raised for the optimistic concurrency.

     

    Best,

    Fabio 

    Monday, May 14, 2007 12:29 PM