Esempio n. 1
0
        PersistenceTestResult TrySave()
        {
            IDataConnection conn = null;

            try
            {
                conn = spec.SessionProvider.GetConnection();
                using (var tran = conn.GetTransactionFactory().GetTransaction())
                {
                    identity = conn.GetPersister().Add(spec.Entity);
                    if (identity == null)
                    {
                        throw new InvalidOperationException($"The entity identity returned by {nameof(IPersister)}.{nameof(IPersister.Add)} should not be null.");
                    }
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                return(new PersistenceTestResult(typeof(T))
                {
                    SaveException = ex
                });
            }
            finally
            {
                conn?.Dispose();
            }

            return(null);
        }