Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.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# .RowFilter中有“IN”和“NOT IN”_C#_Sql - Fatal编程技术网

C# .RowFilter中有“IN”和“NOT IN”

C# .RowFilter中有“IN”和“NOT IN”,c#,sql,C#,Sql,我在将行筛选器应用于DataGridView时遇到问题。我确实需要将RowFilter应用于IN和NOT IN 例如: custId in (select custId from loginDetails where date = '01/11/2010') 注意:我的网格最初加载了CustMaster表中的所有客户详细信息。我需要的是过滤今天登录的客户的登录详细信息。字段custId也是动态的 这可能吗 如果有其他选择,请提供帮助。多年前,我在.net v1中遇到了问题,当IN使用的表发生更

我在将行筛选器应用于DataGridView时遇到问题。我确实需要将RowFilter应用于IN和NOT IN

例如:

custId in (select custId from loginDetails where date = '01/11/2010')
注意:我的网格最初加载了CustMaster表中的所有客户详细信息。我需要的是过滤今天登录的客户的登录详细信息。字段custId也是动态的

这可能吗


如果有其他选择,请提供帮助。

多年前,我在.net v1中遇到了问题,当IN使用的表发生更改时,视图没有更新。我不知道这些天.net framework中是否仍然存在问题。

使用LINQ怎么样

//1. Pick all of those that you do not want in your code.
//2. Select those that you want.
var result = from record in dtLoginDetails.AsEnumerable()
                where //2. Select all records.
                (!( //Remove the ! sign to use IN/NOT IN
                (from custID in dtLoginDetails.AsEnumerable()
                    where custID.Field<string>("author").StartsWith("C") //1. Select those records that are unwanted.
                    //Note that, in your case you can add it like 
                    //unwanted.Field<DateTime>("Date") = DateTime.Now.Date
                select custID.Field<string>("author") 
                )
                .Contains(record.Field<string>("author"))
                )

                )
                select record;

//Cast as DataView
DataView view = result.AsDataView();

当您在日期为'01/11/2010'的loginDetails中选择custId时,实际会发生什么情况?