This is a migrated thread and some comments may be shown as answers.

Get info about valid commites

7 Answers 38 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
darko blazinic
Top achievements
Rank 1
darko blazinic asked on 16 Nov 2015, 02:47 PM
Is it possible to find how much the objects could be validly committed before the error occurred?

7 Answers, 1 is accepted

Sort by
0
Doroteya
Telerik team
answered on 19 Nov 2015, 01:19 PM
Hi Darko,

Thank you for contacting us.

I kindly ask you to provide us with the following details:

1. Which backend do you consume (SQL Server, or Oracle, or PostgreSQL, or else)?
2. What is the scenario on your side (you are interested in the backends' thresholds, you are implementing validation of the data, you are implementing error handling when the operations fail)?

Thank you in advance for your cooperation.

Regards,
Doroteya
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
0
darko blazinic
Top achievements
Rank 1
answered on 19 Nov 2015, 09:46 PM

Hi,

1. beckend is Oracle

2. My scenario : if 80% of inserts (updates or deletes) is OK commit all trans other roll back. Is this possible? 

0
Ralph Waldenmaier
Telerik team
answered on 23 Nov 2015, 09:16 AM
Hello Darko,
Thank you for providing the additional information.
In general, the OpenAccessContext instance is working with transactions. So when you call SaveChanges, then all the necessary operations are fired against the server and a commit is called in the end. This means that either all or no data is commited to the database. In case you want to find out, which operations would happen before the commit, you can use our tracking api to figure this out. You might find this link interesting.

http://docs.telerik.com/data-access/developers-guide/crud-operations/developer-guide-crud-saving

I hope this information is helpful for you.
Do come back in case you have any other question.

Regards,
Ralph Waldenmaier
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.

 
0
darko blazinic
Top achievements
Rank 1
answered on 23 Nov 2015, 03:56 PM
In other words it isn't possible to work with transactions, because it is wrap out to SaveChanges method. So I can't use benefit of ORM in conjunction with custom handling of transaction.
 
0
Ralph Waldenmaier
Telerik team
answered on 24 Nov 2015, 11:05 AM
Hello Darko,
Of course you can handle the transactions in a manual fashion. Please see this link for more details.

http://docs.telerik.com/data-access/feature-reference/api/context-api/feature-ref-api-context-api-handling-transactions

This allows you to handle transactions in a convenient way.
There is also another possibility to handle transactions by using the classic approach. For this you might find this link interesting.

http://www.telerik.com/help/openaccess-classic/using-transactions-in-openaccess.html

Hence, to use the classic approach you need to expose the scope via your context. Please see the following snippet of how to do this.

public partial class MySampleContext : OpenAccessContext
{
    public IObjectScope GetMyScope()
    {
        return base.GetScope();
    }
}

Here I created a partial class of the context and am providing the IObjectScope instance which can be obtained from the OpenAccessContext base class.

I hope this gives you the flexibility you need to handle transactions in your project.
Feel free to ask in case you need further assistance.


Regards,
Ralph Waldenmaier
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.

 
0
darko blazinic
Top achievements
Rank 1
answered on 30 Nov 2015, 10:05 AM

Hello Ralph,

I was try to expose scope as you write, but i keep geting error "The method Begin is not supported for managed transactions."

 public partial class DarkoWebApiDomainContext : OpenAccessContext, IDarkoWebApiDomainContextUnitOfWork     {         public IObjectScope GetDarkoWebApiDomainScope()         {             return base.GetScope();         }

...

and in method call

            DarkoWebApiDomainContext dbContext = new DarkoWebApiDomainContext();              IObjectScope scope = dbContext.GetDarkoWebApiDomainScope();

 scope.Transaction.Begin(); --> error

What I doing wrong?

0
Ralph Waldenmaier
Telerik team
answered on 03 Dec 2015, 08:54 AM
Hi Darko,
You are right, the previously provided GetMyScope can not work with custom transactions since it was bound to the existing context. In order to work with custom transactions, the GetMyScope method must look like this.

public IObjectScope GetMyScope()
{                                   
    return base.GetScope().Database.GetObjectScope();
}

Here you will get a completely isolated object scope which has nothing to do with the context you used to create the object scope.

Revisiting your initial question. You said you want to commit if 80% of your inserts or deletes were successful. You can try to achieve this by flushing chunks of your data to the database and if you have no failure up to a certain point (80%), you can commit that data to the database.
In case of a failure, in order to get the information about the object that failed, you can either enhance the log level to see more details, or examine the exception which will tell you about the failed object.

Do not hesitate to contact us again in case you have any other issue.

Regards,
Ralph Waldenmaier
Telerik
 
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
Tags
Data Access Free Edition
Asked by
darko blazinic
Top achievements
Rank 1
Answers by
Doroteya
Telerik team
darko blazinic
Top achievements
Rank 1
Ralph Waldenmaier
Telerik team
Share this question
or