AJH.CMS.Core.Data.RoleDataMapper.GetRoleById C# (CSharp) Method

GetRoleById() static private method

static private GetRoleById ( int RoleID ) : Role
RoleID int
return AJH.CMS.Core.Entities.Role
        internal static Role GetRoleById(int RoleID)
        {
            Role role = null;

            using (SqlConnection sqlConnection = new SqlConnection(CMSCoreBase.CMSCoreConnectionString))
            {
                SqlCommand sqlCommand = new SqlCommand(SN_ROLE_GET_BY_ID, sqlConnection);
                sqlCommand.CommandType = System.Data.CommandType.StoredProcedure;

                SqlParameter parameter = new SqlParameter(PN_ROLE_ID, System.Data.SqlDbType.Int);
                parameter.Direction = System.Data.ParameterDirection.Input;
                parameter.Value = RoleID;
                sqlCommand.Parameters.Add(parameter);

                sqlCommand.Connection.Open();
                using (SqlDataReader reader = sqlCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                {
                    while (reader.Read())
                    {
                        if (role == null)
                            role = new Role();
                        FillFromReader(role, reader);
                    }
                    reader.Close();
                    sqlCommand.Connection.Close();
                }
            }
            return role;
        }