/// <summary> /// Returns a list of objects which match the values for the fields specified. /// </summary> /// <param name="TournamentId">A field value to be matched.</param> /// <param name="Key">A field value to be matched.</param> /// <returns>The list of TournamentFeeDAO objects found.</returns> public static IList FindByUserIdAndRolePattern(IdType tournamentId, StringType key) { OrderByClause sort = new OrderByClause("TournamentId, Key"); WhereClause filter = new WhereClause("TournamentId = @TournamentId and Key like @Key"); String sql = "Select * from " + VIEW + filter.FormatSql() + sort.FormatSql(); SqlCommand cmd = GetSqlCommand(CONNECTION_STRING_KEY, sql, CommandType.Text); cmd.Parameters.Add(new SqlParameter("@TournamentId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, "TournamentId", DataRowVersion.Proposed, tournamentId.DBValue)); cmd.Parameters.Add(new SqlParameter("@Key", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Key", DataRowVersion.Proposed, key.DBValue)); SqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); IList list = new ArrayList(); while (dataReader.Read()) { list.Add(GetDataObjectFromReader(dataReader)); } dataReader.Close(); return(list); }
/// <summary> /// Returns a list of objects which match the values for the fields specified. /// </summary> /// <param name="Name">A field value to be matched.</param> /// <returns>The list of TournamentDAO objects found.</returns> public static IList FindByName(StringType name, Int32 limit) { OrderByClause sort = new OrderByClause("Name"); WhereClause filter = new WhereClause("Name like @Name + '%'"); String sql = "Select top " + limit.ToString() + " * from " + VIEW + filter.FormatSql() + sort.FormatSql(); SqlCommand cmd = GetSqlCommand(CONNECTION_STRING_KEY, sql, CommandType.Text); cmd.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar, 50, ParameterDirection.Input, false, 0, 0, "Name", DataRowVersion.Proposed, name.DBValue)); SqlDataReader dataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection); IList list = new ArrayList(); while (dataReader.Read()) { list.Add(GetDataObjectFromReader(dataReader)); } dataReader.Close(); return(list); }