Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.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
Linq 类型';不支持序列运算符;system.string';_Linq_Linq To Sql - Fatal编程技术网

Linq 类型';不支持序列运算符;system.string';

Linq 类型';不支持序列运算符;system.string';,linq,linq-to-sql,Linq,Linq To Sql,这个查询有什么问题 var ptypes = (from mf in _pagecontext.PagesRefs let a = mf.nvcr_Slug.Substring(mf.nvcr_Slug.LastIndexOf("/") + 1) // gets everything after / let b = Regex.Replace(a, @"[\d-]+$", m => m.Value

这个查询有什么问题

              var ptypes = (from mf in _pagecontext.PagesRefs
                let a = mf.nvcr_Slug.Substring(mf.nvcr_Slug.LastIndexOf("/") + 1)  // gets everything after /
                let b = Regex.Replace(a, @"[\d-]+$", m => m.Value.Replace('-', '='))   // replace last char with =
                let cc = (b.Contains('=') ? b.Substring(0, b.IndexOf("=")) : b) // strip off everything before = to get original string
                let cm = stroriginal  // string to search
                where cm.Equals(cc)
                select mf); 
nvcr_段塞可能是

mazhar-kaunain-baig-3-4
mazhar-kaunain-baig-3-4/mazhar-kaunain-baig-3-4
mazhar-kaunain-baig-3-4/mazhar-kaunain-baig-3-4/mazhar-kaunain-baig
abc
abc/abc
abc/abc/abc
更新:

根据您的评论,我认为这应该有效:

让b=Regex.Replace(a,@“$”,“=”)

在使用LINQ对集合进行的每次迭代中,您只处理一个值-上面应该捕获给定字符串中的最后一个字符,并将其替换为
=


我能想到的第一件事是LINQ和System之间的冲突。方法
的字符串实现包含
on:

b.Contains('=')

尝试显式使用System.String.Contains。

使用

let cc = (b.Contains("=") ? b.Substring(0, b.IndexOf("=")) : b)

然后再试。

我会问您同样的问题“此查询中存在什么问题”?它给出的序列运算符不支持类型为“system.string”的错误在什么阶段出现错误?i、 是哪一行