Error while deleting category from backend

Posted by Community Admin on 03-Aug-2018 22:57

Error while deleting category from backend

All Replies

Posted by Community Admin on 24-Nov-2011 00:00

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

Posted by Community Admin on 25-Nov-2011 00:00

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

This thread is closed