public void Destroy(TData data) { Logger.LogDebug("Removing data from the Sql database", "SqlDataStore\\Destroy"); try { DateTime start = DateTime.Now; try { Table.DeleteOnSubmit(data); } catch (InvalidOperationException exception) { if (exception.Message != "Cannot remove an entity that has not been attached.") { throw; } Table.Attach(data); DbDataContext.Refresh(RefreshMode.KeepCurrentValues, data); Table.DeleteOnSubmit(data); } DbDataContext.SubmitChanges(); DateTime end = DateTime.Now; Logger.LogDebug(string.Format("Removing data from the Sql database took {0}.", end - start), "SqlDataStore\\Destroy"); } finally { Logger.LogDebug("Removing data from the Sql database... Done", "SqlDataStore\\Destroy"); } }
public void DeploySessionAutoFixationTest() { using (var context = new DbDataContext(_conf.ConnectionStrings.Deployer)) { Deploy deploy; using (var session = new Session(_conf, _user)) { deploy = context.Deploys.Single(d => d.SessionKey == _conf.SessionKey); Assert.That(deploy.Status, Is.EqualTo((int)DeployStatusModel.InProcess)); Assert.Null(deploy.EndUtc); Assert.NotNull(deploy.StartUtc); session.Commit(); } context.Refresh(RefreshMode.OverwriteCurrentValues, context.Deploys); Assert.NotNull(deploy); Assert.NotNull(deploy.EndUtc); Assert.That(deploy.Status, Is.EqualTo((int)DeployStatusModel.Succeed)); } }
public virtual void Update(TData data) { Logger.LogDebug("Updating data in the Sql database", "SqlDataStore\\Update"); try { DateTime start = DateTime.Now; Table.Attach(data); DbDataContext.Refresh(RefreshMode.KeepCurrentValues, data); DbDataContext.SubmitChanges(); DateTime end = DateTime.Now; Logger.LogDebug(string.Format("Updating data in the Sql database took {0}.", end - start), "SqlDataStore\\Update"); } finally { Logger.LogDebug("Updating data to the Sql database... Done", "SqlDataStore\\Update"); } }