Skip to content

Conversation

Mpdreamz
Copy link
Member

There are two aspects that can only be configured using attributes when sometime configuring using regular code is the only way or simply easier. As per #1062 we could already override property names but not whether a property should be ignored when serializing (i.e when calling Index<T>(doc)) or when calling .MapFromAttributes() inside .Map<T>(). As reported by @mausch in #1069

.MapPropertiesFor<T>(props => props
    .Add(p => p.MyProperty, PropertyMapping.Ignored)
    .Add(p => p.SomeProperty, "someprop")
)

…o ignore properties on types without attributes
@Mpdreamz Mpdreamz changed the title Allow properties to be ignored in code when serializing/calling mapattributesfor() Allow properties to be ignored in code when serializing/calling MapFromAttributes() Nov 24, 2014
@gmarz
Copy link
Contributor

gmarz commented Nov 24, 2014

@Mpdreamz This change looks good to me, but one slight nitpick/suggestion...

I wonder if this would be a more intuitive interface:

.MapPropertiesFor<T>(props => props
    .Ignore(p => p.MyProperty)
    .Add(p => p.SomeProperty, "someprop")
)

This way one doesn't have to know about the static Ignored instance of PropertyMapping.

@Mpdreamz
Copy link
Member Author

Excellent suggestion @gmarz

Updated so it uses a dedicated descriptor instead of a fluentdict:

.MapPropertiesFor<T>(props => props
    .Ignore(p => p.MyProperty)
    .Rename(p => p.SomeProperty, "someprop")
)

gmarz added a commit that referenced this pull request Nov 25, 2014
…-code

Allow properties to be ignored in code when serializing/calling MapFromAttributes()
@gmarz gmarz merged commit f02ba5e into develop Nov 25, 2014
@gmarz gmarz deleted the feature/map-attributes-in-code branch November 25, 2014 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants