Dapper + Mysql query uses the LIKE fuzzy wording Pit

LIKE '% @ Title%' would resolve to MySQL function splicing method '%' @ Title '%' splice used here is not enough '%' + @ Title + '%' can only be used
Dynamic GetListByFilter public (ArticleModel filter, PageInfo PageInfo) 
        { 
            String _where = "WHERE =. 1. 1"; 
            (! String.IsNullOrEmpty (filter.Title)) IF 
            { 
                // the LIKE '% @% the Title' would resolve to '%' @ title '%' used here splicing is not acceptable '%' + @ title + ' %' can only MySQL function method splice 
                _where + = "and title the LIKE CONCAT ( '%', @ title, '%')"; 
            } 
            IF (! filter.Status = null) 
            { 
                _where + = "@ and the Status the Status ="; 
            } 
            return GetListByFilter (filter, PageInfo, _where); 
        }

  

Guess you like

Origin www.cnblogs.com/baocaige/p/11115446.html
Recommended