My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
OverridingMappingMechanism  
Overriding the default mapping mechanism
Version-0.2
Updated Mar 24, 2012 by mauricio...@gmail.com

Overriding the default mapping mechanism

By default SolrNet maps Solr fields using attributes. However you might want to use another mapper. Replacing the default mapper depends on how you set up the library:

Built-in container

If you're using the default built-in container, you can replace it like this before calling Startup.Init():

var mapper = new MappingManager();
/* Here come your mappings */
var container = new Container(Startup.Container);
container.RemoveAll<IReadOnlyMappingManager>();
container.Register<IReadOnlyMappingManager>(c => mapper);
Startup.Init<Document>("http://localhost:8983/solr");

Windsor facility

If you're using the Windsor facility, you can override the mapper like this:

var mapper = new MappingManager();
/* Here come your mappings */
var solrFacility = new SolrNetFacility("http://localhost:8983/solr") {Mapper = mapper};
var container = new WindsorContainer();
container.AddFacility("solr", solrFacility);

Ninject module

var mapper = new MappingManager();
/* Here come your mappings */
var c = new StandardKernel();
c.Load(new SolrNetModule("http://localhost:8983/solr") {Mapper = mapper});
Powered by Google Project Hosting