Updating records using view and stored procedures

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
GlennBA
Posts: 21
Joined: Tue 02 Jun 2009 12:58

Updating records using view and stored procedures

Post by GlennBA » Fri 02 Oct 2009 10:59

Hi

This may be a trivial Linq question ...
I am using views and stored procedures.
If I update 10 rows in my UI and use SubmitChanges, the Update SP is called for each row, which is fine.
Problem is, the SP might throw an exception for one of the rows due to logic in the procedure. I can easily catch the exception but how do I know which one of the 10 rows that failed ?
ChangeConflicts is empty. ChangeSet.Updates contains all 10 rows.
So I am stuck.
Do we have to provide logic in the SP to return the failed rows primary key ?

Best regards
Glenn

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Mon 05 Oct 2009 09:04

You should declare the following partial method in your datacontext:

Code: Select all

partial void DataContext.OnSubmitError (Devart.Data.Linq.SubmitErrorEventArgs e);
Then you can select one of possible ContinueActions (Continue, Retry, Abort)

GlennBA
Posts: 21
Joined: Tue 02 Jun 2009 12:58

Post by GlennBA » Mon 05 Oct 2009 11:57

I am not quite sure how to do that:

In a new file I have defined this:
(my dataContext is called AmKurveregDataContext)

Code: Select all

    
partial class AmKurveregDataContext
    {
        partial void OnSubmitError(Devart.Data.Linq.SubmitErrorEventArgs e)
        {
        }
  }
But I get
Error:
No defining declaration found for implementing declaration of partial method 'AmKurvereg.AmKurveregDataContext.OnSubmitError(Devart.Data.Linq.SubmitErrorEventArgs)'
So what more do I need to do ?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Tue 06 Oct 2009 10:23

As a solution, just remove "partial" in the definition.
Then you should be able to maintain errors in this method.

GlennBA
Posts: 21
Joined: Tue 02 Jun 2009 12:58

Post by GlennBA » Tue 06 Oct 2009 10:59

Sorry, but how should this function be called ?
It looks like an eventhandler but shouldn't it be hooked up to something ?

GlennBA
Posts: 21
Joined: Tue 02 Jun 2009 12:58

Post by GlennBA » Tue 06 Oct 2009 11:59

Hi

I have solved my problem like this:

Code: Select all

            try
            {
                Context.SubmitChanges();
            }
            catch (Exception ex)
            {
                    foreach (Devart.Data.Linq.ObjectSubmitError ose in Context.Errors)
The ose contains a reference to the object that failed. Perfect!

Post Reply