More in this section

Forums / General Discussions / ContentItem, GetValue method

ContentItem, GetValue method

2 posts, 0 answered
  1. Vitaly
    Vitaly avatar
    11 posts
    20 Jun 2010
    21 Feb 2011
    Link to this post

    I'm looking for a help with this code:

              var manager = ContentManager.GetManager();
              var item = manager.GetContent().Where(t => (string)t.GetValue("PRODUCT KEY") == key).FirstOrDefault();

    I took it from here:

    It seems to me that when there's a space in argument ("PRODUCT KEY") it doesn't work (err: Unexpected token KEY). I can't rename it now, is there any workaround? Square brackets don't work either.

    unexpected token: [\"KEY\",<42>,line=1,col=143]\r\nOriginal Query: DEFINE EXTENT extnt FOR Telerik.Sitefinity.GenericContent.Model.ContentItem; SELECT * FROM extnt AS t1  WHERE t1.appName =  $1 AND t1.PRODUCT KEY =  $2"

    Thanks in advance!
  2. Bonny
    Bonny avatar
    58 posts
    11 Nov 2016
    23 Feb 2011
    Link to this post
    Hello Vitaly,

    It seems that the problem is in t.GetValue("PRODUCT KEY"). As argument you should put the name of the property that you want. In C# you can't have property with white space in it's name, so this is not valid property. Use the real (valid) property name like ProductKey. Also instead of (string)t.GetValue("PRODUCT KEY"), you can use t.GetValue<String>("PRODUCT KEY").

    Bonny Bonev
    the Telerik team
2 posts, 0 answered