MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Repository Access  (Mono Support )

Viewed 12467 time(s), 3 post(s) 3/24/2016 11:45:33 AMby draven
draven

draven

3/24/2016 11:45:33 AM
Hi.

I'm pretty sure that I am doing something stupid here but I'm really struggling to write custom code that makes use of the repositories. I'm following code snippets from the documentation and support forum but anything similar to this

blog.ApplicationId = MembershipRepository.GetInstance().GetApplicationId();

or this

BlogRepository.GetInstance().SaveBlog(blog, string.Empty);

results in compilation errors of:

Error 4 'MonoSoftware.MonoX.Repositories.MembershipRepository' does not contain a definition for 'GetInstance'

Error 5 'MonoSoftware.MonoX.Repositories.BlogRepository' does not contain a definition for 'GetInstance' 

Are you able to point me in the right direction?

Thanks.
This content has not been rated yet. 
98 Reputation 8 Total posts
khorvat

khorvat

3/24/2016 1:31:01 PM
Hi,

you are probably using code samples from v4.x and running them against v5.x. MonoX v5 had DI architecture s you need to inject or resolve MembershipRepository or BlogRepository and not use GetInstance. You can start by reading the following article which has few guidelines for using DI in MonoX http://monox.mono-software.com/Blog/post/Mono/246/MonoX-CMS-upgrade-guidelines-v4-9-to-v5-1/.
This content has not been rated yet. 
15993 Reputation 2214 Total posts
draven

draven

3/24/2016 2:34:32 PM
Hi,

Thanks for this, I'll give it a go and come back with any other questions.
This content has not been rated yet. 
98 Reputation 8 Total posts