More in this section

Forums / General Discussions / Error while deleting category from backend

Error while deleting category from backend

2 posts, 0 answered
  1. Emil
    Emil avatar
    3 posts
    Registered:
    13 Aug 2011
    24 Nov 2011
    Link to this post

    I'm getting the following error while deleting a category from the backend from a Sitefintiy 4.2 installation.  

    NonGeneric method 'object GetValue(string fieldName)' is not supported in LINQ queries. Use generic 'TValue GetValue<TValue>(string fieldName)' instead.

    any ideas how I can 1) identify the problem or 2) get this to work?

    Thanks

  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    25 Nov 2011
    Link to this post
    Hello Emil,

    Can you please let us know if the exception occurs when trying to remove a particular category from the backend UI, or it's valid for all classifications? Also, have you done any modification to your project prior to the exception occurring? Just in case, you can try removing it using our API. For example:
     
    TaxonomyManager manager = TaxonomyManager.GetManager();
                NewsManager nManager = NewsManager.GetManager();
                var myCategoryId = manager.GetTaxa<HierarchicalTaxon>().Where(t => t.Name == "MyNewsCategory").Single().Id;
                //Get a list of the news items who have the desired category assigned to them
                var newsList = nManager.GetNewsItems().Where(nI=> nI.GetValue<TrackedList<Guid>>("Category").Contains(myCategoryId)).ToList();
                foreach (var newsItem in newsList)
                {
                    var catlist = newsItem.GetValue<TrackedList<Guid>>("Category");
                    //Remove the categopry fromt he list of categories assigned to the item
                    catlist.Remove(myCategoryId);
                    newsItem.SetValue("Category", catlist);
                }
                nManager.SaveChanges();

    Greetings,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered