private static MatchQuery GetQueryMatch(SqlExpression <From> q, string name, IAutoQueryOptions options) { if (options == null) { return(null); } var match = options.IgnoreProperties == null || !options.IgnoreProperties.Contains(name) ? q.FirstMatchingField(name) ?? (name.EndsWith(Pluralized) ? q.FirstMatchingField(name.Substring(0, name.Length - 1)) : null) : null; if (match == null) { foreach (var startsWith in options.StartsWithConventions) { if (name.Length <= startsWith.Key.Length || !name.StartsWith(startsWith.Key)) { continue; } var field = name.Substring(startsWith.Key.Length); match = q.FirstMatchingField(field) ?? (field.EndsWith(Pluralized) ? q.FirstMatchingField(field.Substring(0, field.Length - 1)) : null); if (match != null) { return(new MatchQuery(match, startsWith.Value)); } } } if (match == null) { foreach (var endsWith in options.EndsWithConventions) { if (name.Length <= endsWith.Key.Length || !name.EndsWith(endsWith.Key)) { continue; } var field = name.Substring(0, name.Length - endsWith.Key.Length); match = q.FirstMatchingField(field) ?? (field.EndsWith(Pluralized) ? q.FirstMatchingField(field.Substring(0, field.Length - 1)) : null); if (match != null) { return(new MatchQuery(match, endsWith.Value)); } } } return(match != null ? new MatchQuery(match, null) : null); }