Dapper模糊查询 Like
public async Task<IReadOnlyList<ProductView>> GetProductViewAsync(ProductQueryParameter queryParameter) { if (!string.IsNullOrEmpty(queryParameter.Name)) { queryParameter.Name = $"%{queryParameter.Name}%"; } string sql = "select * from ProductView where (Code=@Code or @Code='') and (Name like @Name or @Name='')" + " and (TechnologyCode=@TechnologyCode or @TechnologyCode='')"; using var conn = _dapperContext.CreateConnection(); var list = await conn.QueryAsync<ProductView>(sql, queryParameter); return list.ToList(); }