dataset.Tables[1].AsEnumerable().Where(row => row.Field<string>("YHLB") == "011").CopyToDataTable() 中YHLB多个筛选条件应该怎么写
时间: 2024-05-19 20:16:29 浏览: 12
你可以使用 && 来连接多个筛选条件,例如:dataset.Tables[1].AsEnumerable().Where(row => row.Field<string>("YHLB") == "011" && row.Field<string>("otherColumn") == "otherValue").CopyToDataTable()。其中,将"otherColumn"和"otherValue"替换为你要添加的其他条件即可。
相关问题
dataset.Tables[1].AsEnumerable().Where(row => row.Field<string>("YHLB") == "011").CopyToDataTable()报错数据源中没有 DataRow请给出优化代码
可以考虑在执行Where()语句之前,先对dataset.Tables[1]进行判空,如果为空,则需要先加载数据源。具体优化代码如下:
if (dataset.Tables.Count > 0 && dataset.Tables[1].Rows.Count > 0)
{
DataTable dt = dataset.Tables[1].AsEnumerable().Where(row => row.Field<string>("YHLB") == "011").CopyToDataTable();
}
else
{
//加载数据源代码
}
private Function<Dataset<Row>, Dataset<Row>> withColumn = jdbcDF -> jdbcDF.withColumn("id", monotonically_increasing_id());
As an AI language model, I understand that the above code is defining a lambda function named "withColumn" that takes in a Dataset of Rows and returns a new Dataset of Rows. The function applies the "withColumn" method on the input dataset to add a new column named "id" with unique monotonically increasing values.
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.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)