public async Task <IEnumerable <string> > GetFilterContent([FromBody] FilterContentRequest filterContentRequest)
 {
     using (var dataAccess = new MasterSideLetterDataAccess(_connectionStrings.MasterSideLetterDb))
     {
         return(await dataAccess.GetFilterContentAsync(filterContentRequest));
     }
 }
        public static async Task <IEnumerable <string> > GetFilterContentAsync(this MasterSideLetterDataAccess dataAccess, FilterContentRequest request)
        {
            var sql = new StringBuilder("select ");

            if (request.FilterLimit > 0)
            {
                sql.Append($" TOP {request.FilterLimit} ");
            }

            sql.Append(" * from (");

            switch (request.FilterType)
            {
            case "Fund":
                sql.Append(
                    @"select distinct Name
                        from Fund
                        where Name like '%' + @TargetText + '%' ");
                break;

            case "Investor":
                sql.Append(
                    @"select distinct Name 
                        from Investor
                        where Name like '%' + @TargetText + '%' ");
                break;

            case "Sponsor":
                sql.Append(
                    @"select distinct SponsorName
                        from v_SponsorNames
                        where SponsorName like '%' + @TargetText + '%' ");
                break;

            case "BusinessUnit":
                sql.Append(
                    @"select distinct BusinessUnitName
                        from v_BusinessUnitNames
                        where BusinessUnitName like '%' + @TargetText + '%' ");
                break;

            case "Strategy":
                sql.Append(
                    @"select distinct StrategyName
                        from v_StrategyNames
                        where StrategyName like '%' + @TargetText + '%' ");
                break;

            case "InvestorType":
                sql.Append(
                    @"select distinct InvestorType
                        from Investor
                        where InvestorType like '%' + @TargetText + '%' ");
                break;

            case "ProvisionType":
                sql.Append(
                    @"select distinct ProvisionType
                        from v_Provision
                        where ProvisionType like '%' + @TargetText + '%' ");
                break;

            case "Entity":
                sql.Append(
                    @"select distinct Entity 
                        from FundInvestor
                        where Entity like '%' + @TargetText + '%' ");
                break;

            case "Counsel":
                sql.Append(
                    @"select distinct Counsel 
                        from FundInvestor
                        where Counsel like '%' + @TargetText + '%' ");
                break;
            }

            sql.Append(") as s");

            return(await dataAccess.QueryAsync <string>(sql.ToString(), request));
        }