Project project = new Project(); project.setpName("新百项目");\ List<Project> list1 = projectMapper.selectAllProject(project);
时间: 2024-03-07 14:49:58 浏览: 24
根据您提供的代码,您实例化了一个 Project 对象,并设置了 pName 属性为 "新百项目",然后将该对象作为参数传递给 selectAllProject 方法。在 selectAllProject 方法中,您应该使用 #{pName} 来获取 Project 对象中的 pName 属性值。但是,根据您的查询语句中的 if 条件,只有当 pName 不为 null 且不为空字符串时,查询语句才会添加相应的条件。因此,如果您的 Project 对象中的 pName 属性值为 null 或者空字符串,查询结果将会是 null。
您可以尝试将 selectAllProject 方法的参数改为使用 @Param 注解指定参数名称,然后在查询语句中使用该参数名称来获取属性值。例如:
```
List<Project> selectAllProject(@Param("pName") String pName, @Param("pManager") String pManager, ...)
```
然后在查询语句中使用 #{pName} 来获取参数值:
```
<if test="pName != null and pName != ''"> and p_name like concat('%', #{pName}, '%')</if>
```
这样,即使您的 Project 对象中的属性值为 null 或者空字符串,也可以正确地进行查询。
相关问题
<component name="RunManager" selected="JavaScript Debug.index.html"> <configuration name="index.html" type="JavascriptDebugType" temporary="true" nameIsGenerated="true" uri="http://localhost:63342/untitled/luqingya/html/index.html" useBuiltInWebServerPort="true"> <method v="2" /> </configuration> <configuration name="weather.js" type="NodeJSConfigurationType" temporary="true" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/js/weather.js" working-dir="$PROJECT_DIR$/js"> <method v="2" /> </configuration> <list> <item itemvalue="JavaScript Debug.index.html" /> <item itemvalue="Node.js.weather.js" /> </list> <recent_temporary> <list> <item itemvalue="JavaScript Debug.index.html" /> <item itemvalue="Node.js.weather.js" /> </list> </recent_temporary> </component> <component name="SvnConfiguration"> <configuration /> </component>改为JSON格式文件
{
"component": [
{
"name": "RunManager",
"selected": "JavaScript Debug.index.html",
"configuration": [
{
"name": "index.html",
"type": "JavascriptDebugType",
"temporary": "true",
"nameIsGenerated": "true",
"uri": "http://localhost:63342/untitled/luqingya/html/index.html",
"useBuiltInWebServerPort": "true",
"method": {
"v": "2"
}
},
{
"name": "weather.js",
"type": "NodeJSConfigurationType",
"temporary": "true",
"nameIsGenerated": "true",
"path-to-js-file": "$PROJECT_DIR$/js/weather.js",
"working-dir": "$PROJECT_DIR$/js",
"method": {
"v": "2"
}
}
],
"list": {
"item": [
{
"itemvalue": "JavaScript Debug.index.html"
},
{
"itemvalue": "Node.js.weather.js"
}
]
},
"recent_temporary": {
"list": {
"item": [
{
"itemvalue": "JavaScript Debug.index.html"
},
{
"itemvalue": "Node.js.weather.js"
}
]
}
}
},
{
"name": "SvnConfiguration",
"configuration": {}
}
]
}
var companyType = towchick.Where(t => t.Project_Name == companyName.Project_Name).ToList();这段代码是什么意思
这段代码是使用 LINQ 查询语法,在集合 `towchick` 中查找 `Project_Name` 与 `companyName.Project_Name` 相同的元素,并将结果存储在一个列表中。具体实现方法是使用 `Where` 方法进行筛选,通过 Lambda 表达式指定筛选条件,使用 `ToList` 方法将筛选结果转换为列表。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)