private static string ParseLiteral(EntityAssociationAttribute attribute) { var literal = attribute.Literal; var quoteLiteral = attribute.QuoteLiteral; var literalDelimeter = quoteLiteral ? BaseQueryUtil.LiteralDelimiter : ""; var value = String.Format("{0}{1}{0}", literalDelimeter, literal); return(value); }
public static string GetSearchValue(EntityAssociationAttribute lookupAttribute, AttributeHolder originalEntity) { if (lookupAttribute.From != null) { var attribute = originalEntity.GetAttribute(lookupAttribute.From); return(attribute == null ? null : attribute.ToString()); } return(lookupAttribute.Literal); }
private static void BuildParentQueryConstraint(CollectionMatchingResultWrapper matchingResultWrapper, AttributeHolder[] attributeHolders, EntityAssociationAttribute lookupAttribute, SearchRequestDto searchRequestDto) { var searchValues = new List <string>(); var enumerable = attributeHolders as AttributeHolder[] ?? attributeHolders.ToArray(); var hasMainEntity = enumerable.Any(); foreach (var entity in attributeHolders) { var key = matchingResultWrapper.FetchKey(entity); var searchValue = SearchUtils.GetSearchValue(lookupAttribute, entity); if (!String.IsNullOrWhiteSpace(searchValue) && lookupAttribute.To != null) { searchValues.Add(searchValue); key.AppendEntry(lookupAttribute.To, searchValue); } } if (searchValues.Any()) { searchRequestDto.AppendSearchEntry(lookupAttribute.To, searchValues); } else if (hasMainEntity && lookupAttribute.Primary) { //if nothing was provided, it should return nothing, instead of all the values --> //if the main entity had a null on a primary element of the composition, nothing should be seen searchRequestDto.AppendSearchEntry(lookupAttribute.To, new[] { "-1231231312" }); } }