Click here to Skip to main content
15,898,035 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
((source as Segment).Parent.AllSegments.GetSegments("2200D","STC").Any(x=>x.GetFieldValue(null,String.Empty, 3).Equals("U")))



Hi this could be simple question but I'm unaware how to resolve it,

basically wt I am trying to achieve is ((source as Segment).Parent.AllSegments.GetSegments("2200D","STC") will return me few fields on the returned fields Iam Checking if Any field that has equal to U. do something....

GetFieldValue is an extension method return type is string, and any return type is bool..its throwing as Cannot Convert expression type string to bool

please give me some suggestions how to resolve it.

What I have tried:

I googled but couldn't find any suitable solution.
Posted
Updated 2-May-16 0:08am
v2
Comments
F-ES Sitecore 3-Apr-16 11:31am    
Something is using a string where a bool is expected. We can't access your system so it's not really possible to help. You need to double check the types of everything and see where the issue is.
Sergey Alexandrovich Kryukov 3-Apr-16 11:46am    
Googling is not what you should mention in "What I have tried". Why using this section if you don't show what you have tried? Show appropriate code sample.
—SA

1 solution

Couple of possibilities:
1) Look at your GetFieldValue method - you are calling it with three parameters: null, a string, and an integer. Check the parameters it expects and make sure they are valid. Then look at exactly what it does with them.
2) Same applies to your GetSegments method: you pass two strings - so look at what happens to them inside the method as well.
The error isn't a compilation error - it's an exception. Which means that it's something to do with the values in the data fields you use inside one of the methods.
I'd start by breakpointing each of them and looking at exactly what is happening in the debugger.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900