public void Attach <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); this.objectContext.AttachTo(this.GetEntitySetName <TEntity>(), entity); }
public void RemoveAffector <TAffector>(TAffector affector) where TAffector : Component, IDamageAffector { ThrowIf.ArgumentIsNull(affector, "affector"); ThrowIf.False((DamageChain)affector.DamageChain == this, "Trying to remove a affector from another chain."); Object.Destroy(affector); }
public NHibernateTransaction( ISessionFactory sessionFactory, IDbConnection connection, IInterceptUnitOfWork[] interceptors, IAuditConfiguration auditConfiguration, IDateTime dateTime, IUserContext userContext, ILogger logger) { ThrowIf.ArgumentIsNull(sessionFactory, "sessionFactory"); ThrowIf.ArgumentIsNull(logger, "logger"); if ((interceptors != null && interceptors.Length != 0) || (auditConfiguration != null && dateTime != null && userContext != null)) { if (connection != null) { this.session = sessionFactory.OpenSession(connection, new SessionInterceptor(interceptors, auditConfiguration, dateTime, userContext)); } else { this.session = sessionFactory.OpenSession(new SessionInterceptor(interceptors, auditConfiguration, dateTime, userContext)); } } else if (connection != null) { this.session = sessionFactory.OpenSession(connection); } else { this.session = sessionFactory.OpenSession(); } this.session.FlushMode = FlushMode.Commit; this.logger = logger; }
public EventQuery(IDbConnectionFactory factory, ISquadQuery squadQuery, IMemberQuery memberQuery) { ThrowIf.ArgumentIsNull(factory); this.connectionFactory = factory; this.squadQuery = squadQuery; this.memberQuery = memberQuery; }
public void Remove <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); this.objectContext.DeleteObject(entity); }
public void Remove <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); this.transaction.Session.Delete(entity); }
public ObservableCollectionProxy(IList <TModel> list, Func <TViewModel, TModel> modelSelectorFunc) { ThrowIf.ArgumentIsNull(list, "list"); ThrowIf.ArgumentIsNull(modelSelectorFunc, "modelSelectorFunc"); this.list = list; this.modelSelectorFunc = modelSelectorFunc; }
public SQLiteUnitOfWorkFactory( INHibernatePersistenceConfiguration configuration, ISessionFactory sessionFactory, IInterceptUnitOfWork[] interceptors, IAuditConfiguration auditConfiguration, IDateTime dateTime, IUserContext userContext, ILogger logger) { ThrowIf.ArgumentIsNull(configuration, "configuration"); ThrowIf.ArgumentIsNull(sessionFactory, "sessionFactory"); ThrowIf.ArgumentIsNull(logger, "logger"); this.sessionFactory = sessionFactory; this.interceptors = interceptors; this.auditConfiguration = auditConfiguration; this.dateTime = dateTime; this.userContext = userContext; this.logger = logger; // Create an in-memory database connection for the factory. This will be (re)used for each // new instance of NHibernateUnitOfWork. this.connection = new SQLiteConnection(SQLiteDatabaseConfigurer.InMemoryConnectionString); this.connection.Open(); // Create the schema in the connection based on the NHibernate mappings configuration.CreateSchema(this.connection); }
public DashboardQuery(IDbConnectionFactory connectionFactory, IIdentityManager identityManager, IValidator <DashboardRequest> validator) { ThrowIf.ArgumentIsNull(connectionFactory); this.connectionFactory = connectionFactory; this.identityManager = identityManager; this.validator = validator; }
public Guid GeneratePlayerReportCard(GenerateReportCardRequest request) { ThrowIf.ArgumentIsNull(request); string sql = @"INSERT INTO PlayerReportCards ( TermId, ReportCardDesignId, PlayerId, Guid, CreatedOn, lastModifiedOn) VALUES( (SELECT TermId FROM EvaluationTerms WHERE Guid = @TermGuid), (SELECT ReportCardDesignId FROM ReportCardDesigns WHERE Guid = @ReportCardDesignGuid), (SELECT PlayerId FROM Players P WHERE Guid = @PlayerGuid AND (P.Deleted IS NULL OR P.Deleted = 0)), @ReportCardGuid, GetDate(), GetDate() );" ; var reportCardGuid = Guid.NewGuid(); DynamicParameters p = new DynamicParameters(); p.Add("@TermGuid", request.TermId.ToString()); p.Add("@ReportCardDesignGuid", request.ReportDesignId.ToString()); p.Add("@ReportCardGuid", reportCardGuid.ToString()); p.Add("@PlayerGuid", request.PlayerId.ToString()); using (var connection = connectionFactory.Connect()) { connection.Open(); connection.ExecuteScalar(sql, p); } return(reportCardGuid); }
public void Detach <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); // Remove the entity from the cache this.transaction.Session.Evict(entity); }
public void Attach <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); // Attach the transient entity to the session this.transaction.Session.Update(entity); }
public void Add <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); // For any transient entity errors, ensure Cascade.SaveUpdate() has been specified in respective References mappings this.transaction.Session.Save(entity); }
public void Add <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); this.objectContext.AddObject(this.GetEntitySetName <TEntity>(), entity); var x = this.objectContext.CreateEntityKey(this.GetEntitySetName <TEntity>(), entity); }
public EntityPersistenceTest(IUnitOfWork unitOfWork, IUnitOfWorkFactory unitOfWorkFactory, IEntityComparer entityComparer) { ThrowIf.ArgumentIsNull(unitOfWork, "unitOfWork"); ThrowIf.ArgumentIsNull(unitOfWorkFactory, "unitOfWorkFactory"); this.unitOfWork = unitOfWork; this.unitOfWorkFactory = unitOfWorkFactory; this.entityComparer = entityComparer; }
public void UpdateCoach(Coach coach) { ThrowIf.ArgumentIsNull(coach); using (var connection = connectionFactory.Connect()) { string sql = GetUpdateStatement(); DynamicParameters p = SetupParameters(coach); connection.Open(); connection.Execute(sql, p); } }
public void Detach <TEntity>(TEntity entity) where TEntity : class { ThrowIf.ArgumentIsNull(entity, "entity"); // TODO: How many, if any, related entities should be detached too? // Remove the entity from the cache this.objectContext.Detach(entity); }
public void UpdateTrainingMaterial(TrainingMaterial trainingMaterial) { ThrowIf.ArgumentIsNull(trainingMaterial); using (var connection = connectionFactory.Connect()) { string sql = GetUpdateStatement(); DynamicParameters p = SetupUpdateParameters(trainingMaterial); connection.Open(); connection.Execute(sql, p); } }
public void UpdatePlayer(Player player) { ThrowIf.ArgumentIsNull(player); using (var connection = connectionFactory.Connect()) { string sql = GetUpdateStatement(); DynamicParameters p = SetupUpdateParameters(player); connection.Open(); connection.Execute(sql, p); } memberQuery.UpdateCache(); }
public PasswordVerificationResult VerifyHashedPassword(string hashedPassword, string providedPassword) { // Throw an error if any of our passwords are null ThrowIf.ArgumentIsNull(() => hashedPassword, () => providedPassword); // Just check if the two values are the same if (hashedPassword.Equals(this.HashPassword(providedPassword))) { return(PasswordVerificationResult.Success); } // Fallback return(PasswordVerificationResult.Failed); }
public void DeletePlayer(Player player) { ThrowIf.ArgumentIsNull(player); using (var connection = connectionFactory.Connect()) { string sql = "UPDATE PLAYERS SET Deleted=1, DeletedOn=GetDate() WHERE Guid = @PlayerGuid"; var p = new DynamicParameters(); p.Add("@PlayerGuid", player.Guid.ToString()); connection.Open(); connection.Execute(sql, p); } memberQuery.UpdateCache(); }
public CoachService(IClubQuery clubQuery, IMemberQuery memberQuery, ICoachRepository coachRepository, IValidator <CoachRequest> validator, IIdentityManager identityManager) { ThrowIf.ArgumentIsNull(clubQuery); ThrowIf.ArgumentIsNull(coachRepository); ThrowIf.ArgumentIsNull(validator); this.clubQuery = clubQuery; this.memberQuery = memberQuery; this.coachRepository = coachRepository; this.validator = validator; this.identityManager = identityManager; }
public void DeleteCoach(Coach coach) { ThrowIf.ArgumentIsNull(coach); using (var connection = connectionFactory.Connect()) { string sql = "UPDATE Coaches SET Deleted=1, DeletedOn=GetDate() WHERE Guid = @CoachGuid"; var p = new DynamicParameters(); p.Add("@CoachGuid", coach.Guid.ToString()); connection.Open(); connection.Execute(sql, p); } memberQuery.UpdateCache(); }
public NHibernateUnitOfWork( INHibernateTransaction transaction, ILogger logger) { ThrowIf.ArgumentIsNull(transaction, "transaction"); ThrowIf.ArgumentIsNull(logger, "logger"); this.unitOfWorkGuid = Guid.NewGuid(); this.transaction = transaction; this.logger = logger; this.logger.LogDebug("NHibernateUnitOfWork(...) '{0}'", this.unitOfWorkGuid); }
public Factory( IEntityFrameworkPersistenceConfiguration configuration, IInterceptUnitOfWork[] interceptors, ILogger logger) { ThrowIf.ArgumentIsNull(configuration, "configuration"); ThrowIf.ArgumentIsNull(interceptors, "interceptors"); ThrowIf.ArgumentIsNull(logger, "logger"); this.configuration = configuration; this.interceptors = interceptors; this.logger = logger; }
public static CameraBlender BlendTo(this Camera camera, Camera target, bool smooth) { ThrowIf.ArgumentIsNull(camera, "camera"); var cameraBlender = camera.gameObject.GetOrAddComponent <CameraBlender>(); cameraBlender.UpdatePosition = true; cameraBlender.UpdateRotation = true; cameraBlender.UpdateFieldOfView = true; cameraBlender.UpdateOrthographicSize = camera.orthographic; cameraBlender.Target = target; cameraBlender.Smooth = smooth; return(cameraBlender); }
public Factory( INHibernatePersistenceConfiguration configuration, IInterceptUnitOfWork[] interceptors, IAuditConfiguration auditConfiguration, IDateTime dateTime, IUserContext userContext, ILogger logger) { ThrowIf.ArgumentIsNull(configuration, "configuration"); ThrowIf.ArgumentIsNull(logger, "logger"); this.sessionFactory = configuration.CreateSessionFactory(); this.interceptors = interceptors; this.auditConfiguration = auditConfiguration; this.dateTime = dateTime; this.userContext = userContext; this.logger = logger; }
public void UpdatePlayerReportCard(UpdateReportCardRequest request) { ThrowIf.ArgumentIsNull(request); var command = GetReportCardUpdateCommand(request); using (var connection = connectionFactory.Connect()) { connection.Open(); using (var transaction = connection.BeginTransaction()) { try { connection.Execute(command.Sql, command.Parameters, transaction); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } } } }
private EntityFrameworkUnitOfWork( ObjectContext objectContext, IInterceptUnitOfWork[] interceptors, ILogger logger) { ThrowIf.ArgumentIsNull(objectContext, "objectContext"); ThrowIf.ArgumentIsNull(interceptors, "interceptors"); ThrowIf.ArgumentIsNull(logger, "logger"); this.unitOfWorkGuid = Guid.NewGuid(); this.objectContext = objectContext; this.objectContext.ContextOptions.LazyLoadingEnabled = true; this.objectContext.ContextOptions.ProxyCreationEnabled = true; this.interceptors = interceptors; this.logger = logger; this.logger.LogDebug("EntityFrameworkUnitOfWork(...) '{0}'", this.unitOfWorkGuid); }
public void AddTerm(TermSetupRequest request) { ThrowIf.ArgumentIsNull(request); string sql = @"INSERT INTO EvaluationTerms (Guid, ClubId, Title, TermStatusId, StartDate, EndDate) VALUES( @TermGuid, (SELECT ClubId FROM Clubs WHERE Guid = @ClubGuid), @Title, 1, @StartDate, @EndDate )" ; DynamicParameters p = new DynamicParameters(); p.Add("@TermGuid", Guid.NewGuid().ToString()); p.Add("@ClubGuid", request.ClubId.ToString()); p.Add("@Title", request.Title); p.Add("@StartDate", request.StartDate); p.Add("@EndDate", request.EndDate); using (var connection = connectionFactory.Connect()) { connection.Open(); connection.Execute(sql, p); } }