Will LINQ to SQL Pick Up Trigger Changes/Errors?
I'm not very knowledgeable about the scope of certain SQL operations and how they relate to LINQ to SQL. If I have a trigger that updates a field in a record after it is inserted, what happens when I insert a new record using LINQ to SQL开发者_开发问答? So given this order of operations:
- Create new "MyObject" instance.
- Assign MyObject properties.
- Insert record using LINQ to SQL.
- SQL Insert Trigger Updates a property of that record to a new value.
Would step 5 be:
"MyObject" holds the updated value.
or
"MyObject" holds the original value that I assigned to it.
And another question given the same steps 1-3:
4.. SQL Trigger throws an error and rolls back the Insert, similar to this example.
Would step 5 be:
LINQ to SQL throws a SQL Exception.
or
???
Answers: 2 and 1
But it's certainly worth testing as well because the exception may depend on connection string params.
精彩评论