|
OverridingMappingMechanism
Overriding the default mapping mechanism
Version-0.2 Overriding the default mapping mechanismBy 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 containerIf 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 facilityIf 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 modulevar mapper = new MappingManager();
/* Here come your mappings */
var c = new StandardKernel();
c.Load(new SolrNetModule("http://localhost:8983/solr") {Mapper = mapper});
|