public List <dynamic> Select(int pageNumber, int pageSize, List <FilterParameter> filter) { if (!_isReadyForUse) { throw new InvalidOperationException("Call \"Build\" method first!"); } DataTranslator translator = new DataTranslator(_metadata); string sql = BuildPagingSelect(filter); List <dynamic> result = new List <dynamic>(); using (SqlConnection connection = new SqlConnection(_metadata.InfoBase.ConnectionString)) using (SqlCommand command = new SqlCommand(sql, connection)) { connection.Open(); command.Parameters.AddWithValue("start", (pageNumber - 1) * pageSize + 1); command.Parameters.AddWithValue("end", pageNumber * pageSize); AddFilterParameters(filter, command.Parameters); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { dynamic item = new ExpandoObject(); translator.Translate(reader, (IDictionary <string, object>)item); result.Add(item); } } } return(result); }
public List <dynamic> Select() { if (!_isReadyForUse) { throw new InvalidOperationException("Call \"Build\" method first!"); } DataTranslator translator = new DataTranslator(_metadata); List <dynamic> result = new List <dynamic>(); using (SqlConnection connection = new SqlConnection(_metadata.InfoBase.ConnectionString)) using (SqlCommand command = new SqlCommand(_select, connection)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { dynamic item = new ExpandoObject(); translator.Translate(reader, (IDictionary <string, object>)item); result.Add(item); } } } return(result); }