Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ private static IPropertyMapping PropertyMappingFromAttributes(MemberInfo memberI
if (ignore == null && propertyName == null && dataMemberProperty == null) return null;

return new PropertyMapping
{ Name = propertyName?.Name ?? dataMemberProperty?.Name, Ignore = ignore != null };
{
Name = propertyName?.Name ?? dataMemberProperty?.Name,
Ignore = ignore != null || propertyName != null && propertyName.Ignore
};
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ namespace Tests.ClientConcepts.HighLevel.Mapping
* === Ignoring properties
* Properties on a POCO can be ignored for mapping purposes in a few ways:
*
* - Using the `Ignore` property on a derived `ElasticsearchPropertyAttribute` type applied to
* - Using the `Ignore` property on a derived `ElasticsearchPropertyAttributeBase` type, such as `TextAttribute`, applied to
* the property that should be ignored on the POCO
*
* - Using the `Ignore` property on `PropertyNameAttribute` applied to a property that should be ignored on the POCO
*
* - Using the `.DefaultMappingFor<TDocument>(Func<ClrTypeMappingDescriptor<TDocument>, IClrTypeMapping<TDocument>>
* selector)` on `ConnectionSettings`
*
Expand All @@ -41,8 +43,11 @@ public class CompanyWithAttributesAndPropertiesToIgnore
[Text(Ignore = true)]
public string PropertyToIgnore { get; set; }

[PropertyName("anotherPropertyToIgnore", Ignore = true)]
public string AnotherPropertyToIgnore { get; set; }

public string FluentMappingPropertyToIgnore { get; set; }

[Ignore, JsonIgnore]
public string JsonIgnoredProperty { get; set; }
}
Expand All @@ -54,7 +59,7 @@ public void Ignoring()
var connectionSettings = new ConnectionSettings(new InMemoryConnection()) // <1> we're using an in-memory connection, but in your application, you'll want to use an `IConnection` that actually sends a request.
.DisableDirectStreaming() // <2> we disable direct streaming here to capture the request and response bytes. In a production application, you would likely not call this as it adds overhead to each call.
.DefaultMappingFor<CompanyWithAttributesAndPropertiesToIgnore>(m => m
.Ignore(p => p.AnotherPropertyToIgnore)
.Ignore(p => p.FluentMappingPropertyToIgnore)
);

var client = new ElasticClient(connectionSettings);
Expand Down