public static void IEntityIdMappingConvention() { var noIdConventions = new ConventionProfile(); noIdConventions.SetIdMemberConvention(new NamedIdMemberConvention("Id")); // no names noIdConventions.SetIgnoreExtraElementsConvention(new AlwaysIgnoreExtraElementsConvention()); ConventionRegistry.Register("noIdConvention", noIdConventions, t => true); }
private static MongoRead RegisterMongoDb() { var readServer = MongoServer.Create(connectionString); var read = new MongoRead(readServer); var myConventions = new ConventionProfile(); myConventions.SetIdMemberConvention(new NoDefaultPropertyIdConvention()); BsonClassMap.RegisterConventions(myConventions, t => true); return(read); }
public LogEntryMongoDataService() { lock (this) { if (!BsonClassMap.IsClassMapRegistered(typeof(LogEntry))) { var noIdConventions = new ConventionProfile(); noIdConventions.SetIdMemberConvention(new NamedIdMemberConvention()); // no names BsonClassMap.RegisterConventions(noIdConventions, t => t == typeof(LogEntry)); BsonClassMap.RegisterClassMap <LogEntry>(cm => cm.AutoMap()); } } }
private IQueryable GetQueryableCollection(string connectionString, Dictionary <string, Type> providerTypes, string collectionName) { var collectionType = CreateDynamicTypeForCollection(collectionName, providerTypes); var conventions = new ConventionProfile(); conventions.SetIdMemberConvention(new NamedIdMemberConvention(MongoMetadata.MappedObjectIdName)); conventions.SetIgnoreExtraElementsConvention(new AlwaysIgnoreExtraElementsConvention()); BsonClassMap.RegisterConventions(conventions, t => t == collectionType); return(InterceptingProvider.Intercept( new MongoQueryableResource(connectionString, collectionName, collectionType), new ResultExpressionVisitor())); }
public void AfterPropertiesSet() { var defaultProfile = ConventionProfile.GetDefault(); _profile = new ConventionProfile(); _filter = new ConventionFilterHelper(IncludeFilters, ExcludeFilters); _profile.SetDefaultValueConvention(DefaultValueConvention ?? defaultProfile.DefaultValueConvention); _profile.SetElementNameConvention(ElementNameConvention ?? defaultProfile.ElementNameConvention); _profile.SetExtraElementsMemberConvention(ExtraElementsMemberConvention ?? defaultProfile.ExtraElementsMemberConvention); _profile.SetIdGeneratorConvention(IdGeneratorConvention ?? defaultProfile.IdGeneratorConvention); _profile.SetIdMemberConvention(IdMemberConvention ?? defaultProfile.IdMemberConvention); _profile.SetIgnoreExtraElementsConvention(IgnoreExtraElementsConvention ?? defaultProfile.IgnoreExtraElementsConvention); _profile.SetIgnoreIfDefaultConvention(IgnoreIfDefaultConvention ?? defaultProfile.IgnoreIfDefaultConvention); _profile.SetIgnoreIfNullConvention(IgnoreIfNullConvention ?? defaultProfile.IgnoreIfNullConvention); _profile.SetMemberFinderConvention(MemberFinderConvention ?? defaultProfile.MemberFinderConvention); _profile.SetSerializationOptionsConvention(SerializationOptionsConvention ?? defaultProfile.SerializationOptionsConvention); BsonClassMap.RegisterConventions(_profile, _filter.Filter); }