Using the Client Object Model (C#) in SharePoint 2010, how can I determine if a specified column (field) name exists in a given List?
Thanks, MagicAndi.
Using the Client Object Model (C#) in SharePoint 2010, how can I determine if a specified column (field) name exists in a given List?
Thanks, MagicAndi.
Some good answers above. I personally used this one:
You can also use 'Where' after Include method and check if returned collection/field is null. It's about personal preference, because both options are querying on client side.
Here's an extension code (CSOM) for sharepoint list
usage
enjoy :)
I prefer the SharePoint Plus Library as it is really clean: http://aymkdn.github.io/SharepointPlus/symbols/%24SP%28%29.list.html
You could setup a for loop to loop through the row and check if the column you're looking for exists.
Just found this while searching for the same thing, but it looks like Sharepoint 2010 has something built in for this, at least for the Server model:
list.Fields.ContainsField("fieldName");
Not sure if it exists for Client side though. Figured it would be a good place to store this information however.
A cut down and simplified version of Mitya's extension method:
There's no need to pass in a separate client context parameter when you can already use the context that comes in with the list.
to much code use this
load Fields first then