MongoDB repository

74 views
Skip to first unread message

cong...@gmail.com

unread,
Mar 23, 2015, 8:58:24 AM3/23/15
to sharpre...@googlegroups.com
Hi,
I'm tryng to test sharprepository with MongoDB on MongoDbLab
I have a problema with connection string, when i get the instance of the default repository:

IRepository<Album,int> albumRepo = RepositoryFactory.GetInstance<Album, int>();
I get :System.FormatException: Invalid Connection String 'MongoDBConn'

If i try a connection with MongoClient with the same connection string goes all ok!


this is my app.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="sharpRepository" type="SharpRepository.Repository.Configuration.SharpRepositorySection, SharpRepository.Repository" />
</configSections>
<sharpRepository>
<repositories default="mongodb">

<repository name="mongodb" connectionString="MongoDBConn" factory="SharpRepository.MongoDbRepository.MongoDbConfigRepositoryFactory, SharpRepository.MongoDbRepository" />
</repositories>
<cachingProviders>
</cachingProviders>
<cachingStrategies>
<cachingStrategy name="standardCachingStrategy" generational="true" writeThrough="true" factory="SharpRepository.Repository.Caching.StandardConfigCachingStrategyFactory, SharpRepository.Repository" />
<cachingStrategy name="timeoutCachingStrategy" timeout="300" factory="SharpRepository.Repository.Caching.TimeoutConfigCachingStrategyFactory, SharpRepository.Repository" />
<cachingStrategy name="noCaching" factory="SharpRepository.Repository.Caching.NoCachingConfigCachingStrategyFactory, SharpRepository.Repository" />
</cachingStrategies>
</sharpRepository>
<connectionStrings>
<add name="MongoDBConn" connectionString="mongodb://myuser:mypas...@xxx.mongolab.com:xxx/mydatabase"/>
</connectionStrings>

</configuration>

Any suggestion?
Thank you

cong...@gmail.com

unread,
Mar 23, 2015, 10:54:57 AM3/23/15
to sharpre...@googlegroups.com, cong...@gmail.com
Ok I understand you have to pass the connection string and non the connectionstring name in the repository section on app.config
Bye
Reply all
Reply to author
Forward
0 new messages