public int Insert(EmployeeInStudyGroup entity) { string procedureName = "EmployeeInStudyGroup_Insert"; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(procedureName, connection) { CommandType = System.Data.CommandType.StoredProcedure }; SqlParameter OtherParam2 = new SqlParameter { ParameterName = "@EmployeeId", Value = entity.EmployeeId }; command.Parameters.Add(OtherParam2); SqlParameter OtherParam1 = new SqlParameter { ParameterName = "@StudyGroupId", Value = entity.StudyGroupId }; command.Parameters.Add(OtherParam1); return((int)command.ExecuteScalar()); } }
public void Update(EmployeeInStudyGroup entity) { string procedureName = "EmployeeInStudyGroup_Update"; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(procedureName, connection) { CommandType = System.Data.CommandType.StoredProcedure }; SqlParameter IdParam = new SqlParameter { ParameterName = "@Id", Value = entity.Id }; command.Parameters.Add(IdParam); SqlParameter OtherParam1 = new SqlParameter { ParameterName = "@EmployeeId", Value = entity.EmployeeId }; command.Parameters.Add(OtherParam1); SqlParameter OtherParam2 = new SqlParameter { ParameterName = "@StudyGroupId", Value = entity.StudyGroupId }; command.Parameters.Add(OtherParam2); command.ExecuteNonQuery(); } }
public IEnumerable <EmployeeInStudyGroup> Select(EmployeeInStudyGroupFilter filter) { string procedureName = "EmployeeInStudyGroup_Select"; using (SqlConnection connection = new SqlConnection(_connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(procedureName, connection) { CommandType = System.Data.CommandType.StoredProcedure }; var paramList = GetFilterParam(filter); foreach (var param in paramList) { SqlParameter Param = new SqlParameter { ParameterName = param.Key, Value = param.Value }; command.Parameters.Add(Param); } var result = command.ExecuteReader(); List <EmployeeInStudyGroup> resultList = new List <EmployeeInStudyGroup>(); if (result.HasRows) { while (result.Read()) { EmployeeInStudyGroup entity = new EmployeeInStudyGroup { Id = result.GetInt32(0), EmployeeId = result.GetInt32(1), StudyGroupId = result.GetInt32(2) }; resultList.Add(entity); } } result.Close(); return(resultList); } }