Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elixneto/CollectionMapper.RavenDB.NetCore
https://github.com/elixneto/CollectionMapper.RavenDB.NetCore
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/elixneto/CollectionMapper.RavenDB.NetCore
- Owner: elixneto
- Created: 2019-10-04T14:12:34.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-30T18:44:21.000Z (8 months ago)
- Last Synced: 2024-07-11T17:09:47.241Z (3 months ago)
- Language: C#
- Size: 84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CollectionMapper.RavenDB.NetCore
An easy way to map your entities classes to RavenDB collections for .NET applications## Wiki
Full Documentation:
https://github.com/elixneto/CollectionMapper.RavenDB.NetCore/wiki## Easy to use
```csharp
public class MyCustomMapper : RavenDBCollectionMapper
{
public MyCustomMapper()
{
Map("MyUniqueAccounts");
Map("SuperSpecialBanks");
Map("USER");
Map("Fruits", typeof(Apple), typeof(Banana), typeof(Strawberry));
...
...
}
}public class RavenDBDocumentStoreHolderExample
{
private readonly MyCustomMapper myCustomMapper = new MyCustomMapper();private static Lazy store = new Lazy(CreateStore);
public static IDocumentStore Store => store.Value;
private static IDocumentStore CreateStore()
{
/* you can ignore private properties of your entities classes */
myCustomMapper.IncludeNonPublicProperties(false);IDocumentStore store = new DocumentStore
{
Urls = new[] { "http://your_RavenDB_cluster_node" },
Database = "your_RavenDB_database_name",
Conventions = {
/* Here you set the collection mapper */
FindCollectionName = (type) => myCustomMapper.FindCollectionBy(type),/* Here you can use the contract resolver to ignore the private properties */
Serialization = new NewtonsoftJsonSerializationConventions
{
JsonContractResolver = myCustomMapper.GetPropertiesContract()
}
}}.Initialize();
return store;
}
}
```