0

I have implemented a search functionality using the LinqKit predicate builder. It is working fine in the local environment and when it is published to a folder the same functionality is not working. The app is published to a folder.

var outerFilter = PredicateBuilder.True<TERP_LS_BUILDING_ENTRY>();
if (codes != null)
{
    outerFilter = outerFilter.And(i => codes.All(c => i.TO_UNIT_NO.Contains(c)));
}

var predicatefilter = PredicateBuilder.False<TERP_LS_BUILDING_ENTRY>();
if (search_text != null && search_text != "")
{
    string searchTextLower = search_text.ToLower().Trim();
    predicatefilter = predicatefilter.Or(i => i.VISITOR_NAME.Contains(searchTextLower));
    predicatefilter = predicatefilter.Or(i => i.TO_UNIT_NO.Contains(searchTextLower));
}
outerFilter.And(predicatefilter);

these are the filters which I have implemented. I have referred the below link.

Predicate Builder documentation

I have tried republishing the app several times but still the same result occurs

6
  • By "not working" what do you mean? Is there an exception, or does it just not return data you expect? What database is your local environment using vs. the published environment? If the two environments are using the same database server but different database instances, a first thing to check would be collation settings on the two databases. If local is case insensitive while the other is case sensitive, that would be a problem for returning data.
    – Steve Py
    Commented Jul 2 at 4:57
  • In local environment I'm getting the data but while publishing the build, the data is getting empty or null.
    – sid
    Commented Jul 2 at 5:03
  • utf8mb4_general_ci this is the collation which is used in the mysql db. I think case sensitivity in not a problem here.
    – sid
    Commented Jul 2 at 6:46
  • I also think that collation can be a problem here. LinqKit do not execute SQL. Commented Jul 2 at 6:49
  • Yeah the _CI means case insensitive. So have you successfully run it locally against a database or just with LinqKit? Debug it locally against an actual database and capture the SQL. If it works on one local database but not published, verify the connection string at runtime by logging _dbContext.Database.GetDbConnection().ConnectionString output somewhere and confirm the deployed environment is actually going to the expected database.
    – Steve Py
    Commented Jul 2 at 10:06

0