Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 要与一个字符串值进行比较的多个字符串值。类似attributetocheck.Equals(att1,att2,att3)的内容_C#_Sql - Fatal编程技术网

C# 要与一个字符串值进行比较的多个字符串值。类似attributetocheck.Equals(att1,att2,att3)的内容

C# 要与一个字符串值进行比较的多个字符串值。类似attributetocheck.Equals(att1,att2,att3)的内容,c#,sql,C#,Sql,我有多个属性,比如att1、att2、att3,可以用任何分隔符来分隔。 我想在下面的查询中使用“或”条件来检查COLUMN1中的行值是否相等。 因为.Equals只能有一个字符串,所以任何人都可以建议其他方法 string result = string.Join(",", attributes); List<string> query = (from DataRow dr in response.Output.Tables[0].Rows

我有多个属性,比如att1、att2、att3,可以用任何分隔符来分隔。 我想在下面的查询中使用“或”条件来检查COLUMN1中的行值是否相等。 因为.Equals只能有一个字符串,所以任何人都可以建议其他方法

string result = string.Join(",", attributes);
            List<string> query = (from DataRow dr in response.Output.Tables[0].Rows
                                         where dr["COLUMN1"].ToString().Equals(result)
                                         select dr["COLUMN2"].ToString()).ToList<string>();
string result=string.Join(“,”属性);
列表查询=(来自响应中的DataRow dr.Output.Tables[0]。行
其中dr[“COLUMN1”].ToString()等于(结果)
选择dr[“COLUMN2”].ToString()).ToList();

使用字符串的Contains方法,而不是将属性连接到字符串

List<string> query = (from DataRow dr in response.Output.Tables[0].Rows                                         
                      where attributes.Contains(dr["COLUMN1"].ToString())
                      select dr["COLUMN2"].ToString()).ToList<string>()
List query=(来自响应中的DataRow dr.Output.Tables[0]。行
其中attributes.Contains(dr[“COLUMN1”].ToString())
选择dr[“COLUMN2”].ToString()).ToList()

您可以尝试
包含
?这两者都是相关的。后者甚至在其应用程序中使用linqanswer@christiandev包含帮助。非常感谢。@Thomas Linq在链接中提供了一些硬代码,在我的代码中提供了这些代码。。感谢帮助。…谢谢。。非常感谢您的详细介绍。谢谢