private string BuildCatalogQuery(CatalogMetaData catalogDefination, CatalogRequest catalogRequest) { StringBuilder Query = new StringBuilder(); Query.Append("Select "); Query.Append(catalogDefination.DisplayColumn); Query.Append(" as Description, "); Query.Append(catalogDefination.ValueColumn); Query.Append(" as Code "); Query.Append(" From "); Query.Append(catalogDefination.TableName); Query.Append(" Where "); if (!catalogRequest.Filter.SearchCodeOnly) { Query.Append(catalogDefination.DisplayColumn); Query.Append(" like @FilterValue"); Query.Append(" Or "); } if (!catalogRequest.Filter.SearchDescriptionOnly) { Query.Append(catalogDefination.ValueColumn); Query.Append(" like @FilterValue"); Query.Append(" Or "); } Query.Append(" @ShowAll = 1"); return(Query.ToString()); }
public CatalogMetaData GetCatalogMetaData(string catalogName) { CatalogMetaData catalogDefination = null; if (catalogName.IsNotNullOrEmpty()) { catalogDefination = CatalogRepository.GetCatalogMetaData(catalogName); } return(catalogDefination); }
public List <CatalogData> GetCatalogData(CatalogRequest catalogRequest) { CatalogMetaData catalogDefination = GetCatalogMetaData(catalogRequest.CatalogId); string catalogFilterQuery = BuildCatalogQuery(catalogDefination, catalogRequest); if (!catalogRequest.Filter.SearchExact) { catalogRequest.Filter.Term = '%' + catalogRequest.Filter.Term + '%'; } return(Connection.Query <CatalogData>(catalogFilterQuery, new { FilterValue = catalogRequest.Filter.Term, ShowAll = catalogRequest.Filter.ShowAll }).ToList()); }
private string GetCatalogDataQuery(CatalogRequest catalogRequest) { CatalogMetaData catalogDefination = GetCatalogMetaData(catalogRequest.CatalogId); string catalogFilterQuery = CatalogQueryProvider.BuildCatalogQuery(catalogDefination, catalogRequest); if (!catalogRequest.Filter.SearchExact) { catalogRequest.Filter.Term = '%' + catalogRequest.Filter.Term + '%'; } return(catalogFilterQuery); }