Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/304.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# 搜索所有3个单词。我尝试动态附加,但失败了。如果您能再次提供帮助,我们将不胜感激。提前感谢您的帮助。谢谢Abdhulla。这也为我提供了一个包含所有“First”和“Employee”事件的数据集。我只想要一个数据集,其中“First”和“Employee_C#_Linq_Datatable - Fatal编程技术网

C# 搜索所有3个单词。我尝试动态附加,但失败了。如果您能再次提供帮助,我们将不胜感激。提前感谢您的帮助。谢谢Abdhulla。这也为我提供了一个包含所有“First”和“Employee”事件的数据集。我只想要一个数据集,其中“First”和“Employee

C# 搜索所有3个单词。我尝试动态附加,但失败了。如果您能再次提供帮助,我们将不胜感激。提前感谢您的帮助。谢谢Abdhulla。这也为我提供了一个包含所有“First”和“Employee”事件的数据集。我只想要一个数据集,其中“First”和“Employee,c#,linq,datatable,C#,Linq,Datatable,搜索所有3个单词。我尝试动态附加,但失败了。如果您能再次提供帮助,我们将不胜感激。提前感谢您的帮助。谢谢Abdhulla。这也为我提供了一个包含所有“First”和“Employee”事件的数据集。我只想要一个数据集,其中“First”和“Employee”都用于相同的l_id,换句话说,其中count(l_id)大于1在新编辑后检查上面显示的代码片段。工作非常出色!非常感谢阿卜杜拉。非常感谢您的回复。你能帮我理解代码是如何工作的吗?我很难理解Linq,尤其是这些聚合函数。再次感谢!不客气:)。


搜索所有3个单词。我尝试动态附加,但失败了。如果您能再次提供帮助,我们将不胜感激。提前感谢您的帮助。谢谢Abdhulla。这也为我提供了一个包含所有“First”和“Employee”事件的数据集。我只想要一个数据集,其中“First”和“Employee”都用于相同的l_id,换句话说,其中count(l_id)大于1在新编辑后检查上面显示的代码片段。工作非常出色!非常感谢阿卜杜拉。非常感谢您的回复。你能帮我理解代码是如何工作的吗?我很难理解Linq,尤其是这些聚合函数。再次感谢!不客气:)。我已经在上面的代码中添加了一些注释。我有一个后续问题,先生-是否可以动态生成此查询?例如,这里我的输入字符串是“FirstEmployee”,因此查询有“First”和“Employee”。假设明天我有一个叫做“First Employee Salary”的东西,然后我需要搜索所有3个词。我尝试动态附加,但失败了。如果您能再次提供帮助,我们将不胜感激。提前感谢您的帮助。
var results = from myRow in dtResult.AsEnumerable()
              where myRow.Field<string>("W_Text") == "First" ||
                    myRow.Field<string>("W_Text") == "Employee"
              select myRow;

dtCopy = results.CopyToDataTable();
var results = (from myRow in dtResult.AsEnumerable()
              where myRow.Field<string>("W_Text") == "First" ||
              myRow.Field<string>("W_Text") == "Employee"
              select myRow ).ToLookup(item => item.Field<string>("l_id"));
var results = (from myRow in dtResult.AsEnumerable()
               where myRow.Field<string>("W_Text") == "First" ||
               myRow.Field<string>("W_Text") == "Employee"
               select myRow).GroupBy(item => item.Field<string>("l_id")).ToList();
      List<string> wTextFilter = new List<string>();
        wTextFilter.Add("First");
        wTextFilter.Add("Employee");

        // Get all Id's that satisfy all conditions:            
        List<int> results = dt.AsEnumerable()
            // Get all Id's:
            .Select(dataRow => dataRow.Field<int>("l_id"))
            // Filter the Id's : 
            .Where(id =>
                // the Id should be greater than one.
                    id > 1   &&
                    // check if all W_Text entries has a record in the datatable with the same Id.
                    wTextFilter.All(W_Text => dt.AsEnumerable().Any(dataRow => dataRow.Field<string>("W_Text") == W_Text && dataRow.Field<int>("l_id") == id)))
                    .Distinct().ToList();

        // Get all datatable rows filtered by the list of Id's.
        DataTable dtCopy = dt.AsEnumerable().Where(dataRow => results.Contains((dataRow.Field<int>("l_id")))).CopyToDataTable();