Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.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# 具有where条件中int列表的contains方法的Linq查询_C#_String_Linq_List_Split - Fatal编程技术网

C# 具有where条件中int列表的contains方法的Linq查询

C# 具有where条件中int列表的contains方法的Linq查询,c#,string,linq,list,split,C#,String,Linq,List,Split,我不明白这个语法有什么错 tags="abc,xyz,asdf" List<string> ta= tags.Split(',').ToList<string>(); List<string> demo = from T in db.tokens where ta.Contains(T.tname) select T.Id; 我有一个表,表中有标签和它们的ID。我需要从表中获取标签的ID。。。 多谢各位 编辑:: 我把它改成了这样,它工作正常,还有另一个问题

我不明白这个语法有什么错

tags="abc,xyz,asdf"
List<string> ta= tags.Split(',').ToList<string>();
List<string> demo = from T in db.tokens where ta.Contains(T.tname) select T.Id;
我有一个表,表中有标签和它们的ID。我需要从表中获取标签的ID。。。 多谢各位

编辑:: 我把它改成了这样,它工作正常,还有另一个问题

List<int> demo = from T in db.tokens where ta.Contains(T.tname) select T.Id).ToList();
var slist = from I in db.institutes
                    from T in db.inst_to_token
                    where I.CountryId == cont
                       && demo.Contains(T.tokenid)
            select I;
但是上面显示的是where条件下的错误


System.collection.generic.List.Containsint的最佳重载方法匹配具有一些无效参数

由于T.tokenid是一个int?,您需要选择inst_to_令牌,其中tokenid不为null,并将T.tokenid.Value传递给demo.Contains方法


T.Id的类型是什么?是字符串吗?如果您有其他问题,请询问其他问题Yes Selman22,您是对的…System.collection.generic.List.ContainsIt的最佳重载方法匹配有一些无效参数…顺便说一句,tokenid的数据类型是完整的。您确定T.tokenid是整数吗?不完整?非常感谢你,埃卡德。
var slist = from I in db.institutes
                from T in db.inst_to_token
                where I.CountryId == cont
                   && T.tokenid.HasValue
                   && demo.Contains(T.tokenid.Value)
        select I;