public void LoadParameters() { SqlParameter sqlSessionParameter = new SqlParameter("@SessionId", GlymaSession.Session.Id); using (IDbConnectionAbstraction parametersDbConnection = GlymaSession.ConnectionFactory.CreateParametersDbConnection()) { SqlCommand selectParametersFromId = new SqlCommand(SelectParametersFromSessionId, parametersDbConnection.Connection); selectParametersFromId.Parameters.Add(sqlSessionParameter); parametersDbConnection.Open(); IDataReader parameters = selectParametersFromId.ExecuteReader(); while (parameters.Read()) { MapParameter parameter = new MapParameter(); parameter.LoadSessionObject(parameters); AddParameter(parameter); } parametersDbConnection.Close(); } }
public MapParameter this[Guid parameterId] { get { if (ParameterContainer.ContainsKey(parameterId)) { return(ParameterContainer[parameterId]); } else { SqlParameter parameterIdSqlParameter = new SqlParameter("@ParameterId", parameterId); using (IDbConnectionAbstraction parametersDbConnection = GlymaSession.ConnectionFactory.CreateParametersDbConnection()) { SqlCommand getParameter = new SqlCommand("SELECT * FROM [Parameters] WHERE [ParameterUid] = @ParameterId;", parametersDbConnection.Connection); getParameter.Parameters.Add(parameterIdSqlParameter); parametersDbConnection.Open(); IDataReader parameters = getParameter.ExecuteReader(); MapParameter parameter = null; while (parameters.Read()) { parameter = new MapParameter(); parameter.LoadSessionObject(parameters); AddParameter(parameter); } parametersDbConnection.Close(); return(parameter); } } } }