Unknown method GetScope of OpenAccessDataProvider

Posted by Community Admin on 05-Aug-2018 17:20

Unknown method GetScope of OpenAccessDataProvider

All Replies

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

Ive upgraded to 4.1 and I've updated my Products Module code to match the code from Slavo's post here. 
http://www.sitefinity.com/blogs/slavoingilizov/posts/11-04-07/changes_in_mapping_persistent_classes_in_custom_modules_with_sitefinity_4_1.aspx

After correcting the fact that ProductsFluentMetaDataSource attempts to override a non existent method and stubbing out the new members that were added to the ILocatable interface, I noticed that anywhere that scope is accessed through this.GetScope a compilation error occiurs 

Unknown method GetScope of OpenAccessDataProvider
GetScope is still there, but it's been marked internal :/
So now this code here no longer works.. Can someone tell me how these operations changed with the latest version of OpenAccess?

// Always use this method. Do NOT change it to query. Catch the exception if the Id can be wrong.
  var productItem = this.GetScope().GetItemById<ProductItem>(id.ToString());
  ((IDataItem)productItem).Provider = this;
  return productItem;

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

Hello Drew,

You need to use this.GetContext() instead.

Cheers,
Duneel

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

Thanks, that got it

// Always use this method. Do NOT change it to query. Catch the exception if the Id can be wrong.
           var productItem = this.GetContext().GetItemById<ProductItem>(id.ToString());
           ((IDataItem)productItem).Provider = this;
           return productItem;

This thread is closed