当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Can't use 'contains' in LINQ

问题描述:

string last = url.Substring(url.LastIndexOf('/') + 1);

var provisionedSiteRequestRep = provisioningRequestRepository.SelectFirst(new WhereSpecification<ProvisioningRequest>(result => result.SiteUrl.Contains(last.ToString())));

Some time i am getting the null values of last.tosting() so i am getting exception for this code how to resolve this?

网友答案:

You are facing problem on this line

 (result => result.SiteUrl.Contains(last.ToString());

Can you please check that SiteUrl is type of string otherwise it not going to work for you. because last is type of string and Contains is method supported by string type ...

or

otherwise last need to be enumebrable collection and siteurl also enumerable collection than and only than Contains is supported

分享给朋友:
您可能感兴趣的文章:
随机阅读: