Current filter:
                                You should refresh the page.
                                  • Hello

                                    I have searched the support center but I cant find a solution/sample.

                                    As I understand, there is no way to use Explicit Transaction with ThreadSafeDataLayer, which is recommended way to use XPO on ASP.NET.

                                    I have a Firebird database I am able to use stored procedures with standart ADO.NET Firebird Provider.

                                    Is there a way to use stored procedures within transaction with ThreadSafeDataLayer ?

                                    If yes, please provide me a sample.

                                    If no, please provide me a way how to use stored procedures within transaction

                                1 Solution

                                Creation Date Importance Sort by
                                Hello Emin,

                                XPO does not provide a public API for managing database transactions manually except for the Explicit Transactions feature. As far as I understand, you want to modify data using XPO and a stored procedure in the same transaction. To do this, create a separate SimpleDataLayer that is not shared between threads and perform these operations in a Session connected to it. Here is an example:

                                [C#]
                                using DevExpress.Data.Filtering; using DevExpress.Xpo; using DevExpress.Xpo.DB; string connectionString = MSSqlConnectionProvider.GetConnectionString("(local)", "Database1"); using (IDataLayer dataLayer = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.None)) { using (UnitOfWork unitOfWork = new UnitOfWork(dataLayer)) { unitOfWork.ExplicitBeginTransaction(); try { Contact contact = unitOfWork.FindObject<Contact>(new BinaryOperator("FirstName", "Karl")); contact.LastName = "test"; unitOfWork.CommitChanges(); unitOfWork.ExecuteNonQuery("update Contact set NickName='test' where Oid = '" + contact.Oid.ToString() + "'"); unitOfWork.ExplicitCommitTransaction(); } catch { unitOfWork.ExplicitRollbackTransaction(); } } }


                                If this solution does not meet your needs, describe your scenario in greater detail.

                                • emin.ak 11.13.2018
                                  Hello Anatol

                                  Thanks for your reply.

                                  ı dont know how to create a seperate SimpleDataLayer. I am setting database connection on the first Page load
                                • Anatol (DevExpress Support) 11.14.2018
                                  Hello Emin,

                                  Here is an example:
                                  [C#]
                                  using DevExpress.Data.Filtering; using DevExpress.Xpo; using DevExpress.Xpo.DB; string connectionString = MSSqlConnectionProvider.GetConnectionString("(local)", "Database1"); IDataLayer dataLayer = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.None); UnitOfWork unitOfWork = new UnitOfWork(dataLayer); unitOfWork.ExplicitBeginTransaction(); try { Contact contact = unitOfWork.FindObject<Contact>(new BinaryOperator("FirstName", "Karl")); contact.LastName = "test"; unitOfWork.CommitChanges(); unitOfWork.ExecuteNonQuery("update Contact set NickName='test' where Oid = '" + contact.Oid.ToString() + "'"); unitOfWork.ExplicitCommitTransaction(); } catch { unitOfWork.ExplicitRollbackTransaction(); } unitOfWork.Dispose(); dataLayer.Dispose();


                                  You can find more information in our documentation: Data Access Layer.

                                • emin.ak 11.14.2018
                                  Thank you for you sample Anatol