public override void Map(BsonClassMap <StatusEventDto> cm) { cm.SetDiscriminator("status"); cm.MapProperty(p => p.FromStatus).SetElementName("fromStatus"); cm.MapProperty(p => p.ToStatus).SetElementName("toStatus"); }
public override void Map(BsonClassMap <PriorityEventDto> cm) { cm.SetDiscriminator("priority"); cm.MapProperty(p => p.FromPriority).SetElementName("fromPriority"); cm.MapProperty(p => p.ToPriority).SetElementName("toPriority"); }
protected override void Configure(BsonClassMap <Money> builder) { builder.AutoMap(); builder.MapProperty("Amount"); builder.MapProperty("Currency"); }
public override void Map(BsonClassMap <TicketEventDto> cm) { cm.MapIdProperty(x => x.Id); cm.MapProperty(x => x.TicketId).SetElementName("ticketId"); cm.MapProperty(x => x.Created).SetElementName("created"); cm.MapProperty(x => x.UserId).SetElementName("userId"); }
public override void Map(BsonClassMap <FileUpload> cm) { cm.MapProperty(f => f.Created).SetElementName("created"); cm.MapProperty(f => f.Id).SetElementName("id"); cm.MapProperty(f => f.Name).SetElementName("name"); cm.MapProperty(f => f.Type).SetElementName("type"); cm.MapProperty(f => f.Data).SetElementName("data"); }
public override void Map(BsonClassMap <FileDto> cm) { cm.MapIdProperty(x => x.Id); cm.MapProperty(f => f.Created).SetElementName("created"); cm.MapProperty(f => f.Id).SetElementName("id"); cm.MapProperty(f => f.Name).SetElementName("name"); cm.MapProperty(f => f.Type).SetElementName("type"); }
public override void Map(BsonClassMap <HistoricalReadModel> config) { config.MapProperty(t => t.CreatedBy).SetElementName("CreatedBy"); config.MapProperty(t => t.CreatedAt).SetElementName("CreatedAt") .SetSerializer(new DateTimeSerializer(DateTimeKind.Local)); config.MapProperty(t => t.UpdatedBy).SetElementName("UpdatedBy"); config.MapProperty(t => t.UpdatedAt).SetElementName("UpdatedAt") .SetSerializer(new DateTimeSerializer(DateTimeKind.Local)); }
public override void Map(BsonClassMap <ReceiptItem> config) { config.AutoMap(); config.SetIgnoreExtraElements(true); config.MapProperty(t => t.Title).SetElementName("Title"); config.MapProperty(t => t.Description).SetElementName("Description"); config.MapProperty(t => t.Price).SetElementName("Price") .SetSerializer(new DecimalSerializer(BsonType.Decimal128)); config.MapProperty(t => t.Quantity).SetElementName("Quantity"); }
public override void Map(BsonClassMap <Article> cm) { cm.AutoMap(); cm.MapIdProperty(c => c.Id); cm.MapProperty(c => c.Title).SetElementName("title"); cm.MapProperty(c => c.Author).SetElementName("author"); cm.MapProperty(c => c.Summary).SetElementName("summary"); cm.MapProperty(c => c.Content).SetElementName("content"); cm.SetIgnoreExtraElements(true); }
public override void Map(BsonClassMap <Receipt> config) { config.AutoMap(); config.SetIgnoreExtraElements(true); config.MapProperty(t => t.Date).SetElementName("Date") .SetSerializer(new DateTimeSerializer(DateTimeKind.Local)); config.MapProperty(t => t.Description).SetElementName("Description"); config.MapProperty(t => t.CampaignId).SetElementName("CampaignId"); config.MapProperty(t => t.ReceiptItems).SetElementName("ReceiptItems"); config.MapProperty(t => t.Tags).SetElementName("Tags"); }
public override void Map(BsonClassMap <Todo> cm) { cm.AutoMap(); //every doc has to have an id cm.MapIdField(x => x.Id); cm.MapProperty(x => x.State); cm.MapProperty(x => x.IsDone); cm.SetIgnoreExtraElements(true); // will set the element name to "sp" in the stored documents //unmap the property.. now we won't save it }
public static BsonMemberMap MapRequired <TInstance, TProperty>( this BsonClassMap <TInstance> mapper, Expression <Func <TInstance, TProperty> > propertyExpression) where TInstance : class => mapper .MapProperty(propertyExpression) .SetIsRequired(true);
public EventStore(IEventPublisher publisher, CQRSCode.ReadModel.Repository.MongoOptions mongoOptions, IList <EventType> events) { _publisher = publisher; if (!BsonClassMap.IsClassMapRegistered(@events[0].Type)) { // Insuffisant car quand les entités sont enregistrées en tant que IEvent, seuls les champs de l'interface sont persistés // BsonClassMap.RegisterClassMap<ProductCreated>(cm => { cm.AutoMap(); cm.unmap } ); // BsonClassMap.RegisterClassMap<OfferCreated>(); // BsonClassMap.RegisterClassMap<OfferStockSet>(); // BsonClassMap.RegisterClassMap<EventBase>(cm => { // cm.MapIdProperty(eb => eb._id).SetIdGenerator(MongoDB.Bson.Serialization.IdGenerators.BsonObjectIdGenerator.Instance); // }); // Impossible d'utiliser automap et de définir un autre champ ID que .Id // BsonClassMap.RegisterClassMap<OfferCreated>(cm => // { // cm.MapProperty(o => o.Id); // Nécessaire de mapper en tant que simple propriété afin que ce champ ne soit pas défini comme l'ID du document (_id) dans Mongo // cm.AutoMap(); // //cm.GetMemberMapForElement("_id").SetIdGenerator(MongoDB.Bson.Serialization.IdGenerators.BsonObjectIdGenerator.Instance); // }); foreach (var @event in events) { BsonClassMap m = new BsonClassMap(@event.Type); @event.Type.GetProperties().ToList().ForEach(p => m.MapProperty(p.Name)); BsonClassMap.RegisterClassMap(m); } } _client = new MongoClient(mongoOptions.ConnectionString); _database = _client.GetDatabase(mongoOptions.Database); _collection = _database.GetCollection <IEvent>("events"); }
public static BsonMemberMap MapOptional <TInstance, TProperty>( this BsonClassMap <TInstance> mapper, Expression <Func <TInstance, TProperty> > propertyExpression) where TInstance : class => mapper .MapProperty(propertyExpression) .SetIgnoreIfNull(true);
public override void Map(BsonClassMap <PriorityDto> cm) { cm.MapIdProperty(x => x.Id); cm.MapProperty(x => x.Name) .SetElementName("name"); }
private static void MapProperties <T>(PropertyInfo[] propertyInfos, BsonClassMap <T> c) where T : IDomainEvent { foreach (var property in propertyInfos) { c.MapProperty(property.Name); } }
protected override void Configure(BsonClassMap <TTN> builder) { builder.AutoMap(); builder.MapCreator(x => new TTN(x.Value)); builder.MapProperty(x => x.Value); }
public static BsonMemberMap MapOffsetDateTime <T>( this BsonClassMap <T> mapper, Expression <Func <T, OffsetDateTime?> > datetimePropertyExpression) where T : class => mapper .MapProperty(datetimePropertyExpression) .SetIgnoreIfNull(true) .SetSerializer(NullableOffsetDateTimeMongoSerializer.Instance);
public static BsonMemberMap MapOffsetDateTime <T>( this BsonClassMap <T> mapper, Expression <Func <T, OffsetDateTime> > datetimePropertyExpression, bool isRequired = true) where T : class => mapper .MapProperty(datetimePropertyExpression) .SetIsRequired(isRequired) .SetSerializer(OffsetDateTimeMongoSerializer.Instance);
public static BsonMemberMap MapGuid <T>( this BsonClassMap <T> mapper, Expression <Func <T, Guid> > guidPropertyExpression, bool isRequired = true) where T : class => mapper .MapProperty(guidPropertyExpression) .SetIsRequired(isRequired) .SetSerializer(GuidMongoSerializer.Instance);
public static void GetClassMap(BsonClassMap cm) { cm.MapProperty(nameof(Rounds)); cm.MapProperty(nameof(AttackerCasualties)); cm.MapProperty(nameof(DefenderCasualties)); cm.MapProperty(nameof(DuelTies)); cm.MapProperty(nameof(Duels)); cm.MapProperty(nameof(AttackerVictory)); cm.MapProperty(nameof(AverageLevelDifference)); cm.MapProperty(nameof(TacticalAdvantage)); }
public override void Map(BsonClassMap <TicketDto> cm) { cm.MapIdProperty(x => x.Id); cm.MapProperty(x => x.Description) .SetElementName("description"); cm.MapProperty(x => x.Priority) .SetElementName("priority"); cm.MapProperty(x => x.Status) .SetElementName("status"); cm.MapProperty(x => x.Title) .SetElementName("title"); cm.MapProperty(x => x.Files) .SetElementName("files"); }
public override void Map(BsonClassMap <MyClass> cm) { cm.AutoMap(); //every doc has to have an id cm.MapIdField(x => x.Id).SetIdGenerator(new StringObjectIdGenerator()); cm.MapProperty(x => x.SomeProperty) .SetElementName("sp"); // will set the element name to "sp" in the stored documents //unmap the property.. now we won't save it cm.UnmapProperty(x => x.SomeOtherProperty); }
protected override void Configure(BsonClassMap <Order> builder) { builder.MapProperty(x => x.Identifier); builder.MapProperty(x => x.Price); builder.MapProperty(x => x.Description); builder.MapProperty(x => x.Status); builder.MapProperty(x => x.SenderLocation); builder.MapProperty(x => x.RecipientLocation); builder.MapProperty(x => x.CurrentLocation); builder.MapField("_cargos").SetElementName(nameof(Order.Cargos)); }
public static void RequirePropertySetters <T>(this BsonClassMap <T> classMap) { var properties = typeof(T).GetProperties( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance ); foreach (var property in properties.Where(p => p.CanRead && !p.CanWrite)) { throw new ArgumentException( $"Setters are required on property {property.Name} in class {typeof(T)} to allow snapshots" ); } foreach (var property in properties.Where(p => p.CanRead && p.CanWrite)) { classMap.MapProperty(property.Name); } }
public void Apply(BsonClassMap classMap) { var readOnlyProperties = classMap .ClassType .GetTypeInfo() .GetProperties(_bindingFlags) .Where(propInfo => IsReadOnlyProperty(classMap, propInfo)) .ToList(); foreach (var property in readOnlyProperties) { classMap.MapMember(property); } if (classMap.ClassType.Name.Equals("Event")) { classMap.MapField("_version"); classMap.MapProperty("Version"); } }
public override void Map(BsonClassMap <CommentEventDto> cm) { cm.SetDiscriminator("comment"); cm.MapProperty("Comment").SetElementName("comment"); }
protected override void Configure(BsonClassMap <CargoNumber> builder) { builder.MapProperty(x => x.Number).SetSerializer(new GuidSerializer()); }
protected override void MapEntity(BsonClassMap <Person> cm) { cm.MapIdField(x => x.Id).SetIdGenerator(new ObjectIdGenerator()); cm.MapProperty(x => x.Name); cm.MapProperty(x => x.Age); }
public override void Map(BsonClassMap <FileContentDto> cm) { cm.MapProperty(f => f.Data).SetElementName("data"); }