protected virtual List<String> ParseFields(IDatabaseObject query) { List<String> parsed = new List<String>(); // If we have a distinct field, but no specific fields if (query.Any(attribute => attribute is Distinct) == true && query.Any(logical => logical is Field) == false) { parsed.Add("DISTINCT *"); } // If we have a distinct field and only one field available else if (query.Any(attribute => attribute is Distinct) == true && query.Count(logical => logical is Field) == 1) { Field field = query.First(logical => logical is Field) as Field; if (field != null) { field.Add(query.First(attribute => attribute is Distinct)); parsed.Add(this.ParseField(field)); } } // Else, no distinct in the global query space else { parsed.AddRange(query.Where(logical => logical is Field).Select(field => this.ParseField(field as Field))); } return parsed; }