哎呀,Linq声明的问题 [英] Oops, Problems of the Linq statements
问题描述
如果我想改变这个"_clientContext.Load(_spGroupCol,groupCol => groupCol.Include(groupItem => groupItem.Title)。那么(groupItem => groupItem.Title ==(" ja-JP")));"包含"ja-JP"在组项目中。我应该如何改变
。
您好,如果您发现我的评论非常有帮助那么请提出答案| 。谢谢和问候。
这是Linq的限制,包含可以不能在Linq语句中使用,它不会识别这样的操作,你可以在StackExchange中检查相同的问题:
使用Sharepoint Client Model时出错:'Contains'成员不能在表达式中使用
对此的解决方法,如果要检查组标题是否包含某些字符,我们可以使用String.Contains进行这样的验证:
var _spGroupCol = web.SiteGroups;
clientContext.Load(_spGroupCol,groupCol => groupCol.Include(groupItem => groupItem.Title));
clientContext.ExecuteQuery();
foreach(_spGroupCol中的组项)
{
if(item.Title.Contains(" ja-JP"))
{
//在这里做逻辑
}
}谢谢
最好的问候
Hi,
If I wanna change this "_clientContext.Load(_spGroupCol, groupCol => groupCol.Include(groupItem => groupItem.Title).Where(groupItem => groupItem.Title == ("ja-JP")));" to Contains "ja-JP" in the Group Item. How should I change it.?
Hi there, if you found my comment very helpful then please | Propose as answer | . Thanks and Regards.
Hi,
This is the limitation of Linq, Contains can't be used in Linq Statement, it won't recognize such operation, you could check the same question in StackExchange:
The workaround for this, if want to check if the group title contains some character, we could use String.Contains to do a validation like this:
var _spGroupCol = web.SiteGroups; clientContext.Load(_spGroupCol, groupCol => groupCol.Include(groupItem => groupItem.Title)); clientContext.ExecuteQuery(); foreach (Group item in _spGroupCol) { if (item.Title.Contains("ja-JP")) { //Do logic here } }Thanks
Best Regards
这篇关于哎呀,Linq声明的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!