You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To wrap up, the precedence in which field names are inferred is:
463
464
464
-
1) A naming of the property on `ConnectionSettings` using `.PropertyName()`
465
-
2) A NEST `PropertyNameAttribute`
466
-
3) Ask the serializer if the property has a verbatim value, e.g. it has a `JsonPropertyAttribute` if using {nuget}/NEST.JsonNetSerializer[`JsonNetSerializer`]
467
-
4) See if the `MemberInfo` has a `DataMemberAttribute` applied
468
-
5) Pass the `MemberInfo` to the `DefaultFieldNameInferrer`, which by default will camel case the `Name` property
465
+
. A naming of the property on `ConnectionSettings` using `.PropertyName()`
466
+
467
+
. A NEST `PropertyNameAttribute`
468
+
469
+
. Ask the serializer if the property has a verbatim value, e.g. it has a `JsonPropertyAttribute` if using {nuget}/NEST.JsonNetSerializer[`JsonNetSerializer`]
470
+
471
+
. See if the `MemberInfo` has a `DataMemberAttribute` applied
472
+
473
+
. Pass the `MemberInfo` to the `DefaultFieldNameInferrer`, which by default will camel case the `Name` property
469
474
470
475
The following example class will demonstrate this precedence
471
476
@@ -508,7 +513,8 @@ class Precedence
508
513
509
514
<6> We are going to register a DefaultFieldNameInferrer on ConnectionSettings that will uppercase all properties.
510
515
511
-
Here we create a custom serializer that renames any property named `AskSerializer` to `ask`
516
+
We'll create a custom `IPropertyMappingProvider` that renames any property named `AskSerializer` to `ask`.
517
+
and hook it up when creating the Connection Settings in the following section.
512
518
513
519
[source,csharp]
514
520
----
@@ -523,18 +529,23 @@ class CustomPropertyMappingProvider : PropertyMappingProvider
523
529
}
524
530
----
525
531
526
-
Here we provide an explicit rename of a property on `ConnectionSettings` using `.PropertyName()`
527
-
and all properties that are not mapped verbatim should be uppercased
532
+
Now, when we create the Connection Settings to use to configure the client, we'll add
533
+
534
+
* a default mapping for the `Precedence` type
535
+
536
+
* our `CustomPropertyMappingProvider`
537
+
538
+
* a delegate to perform default field name inference
@@ -423,11 +424,11 @@ public void ExpressionsAreCachedButSeeDifferentTypes()
423
424
* ==== Inference Precedence
424
425
* To wrap up, the precedence in which field names are inferred is:
425
426
*
426
-
* 1) A naming of the property on `ConnectionSettings` using `.PropertyName()`
427
-
* 2) A NEST `PropertyNameAttribute`
428
-
* 3) Ask the serializer if the property has a verbatim value, e.g. it has a `JsonPropertyAttribute` if using {nuget}/NEST.JsonNetSerializer[`JsonNetSerializer`]
429
-
* 4) See if the `MemberInfo` has a `DataMemberAttribute` applied
430
-
* 5) Pass the `MemberInfo` to the `DefaultFieldNameInferrer`, which by default will camel case the `Name` property
427
+
* . A naming of the property on `ConnectionSettings` using `.PropertyName()`
428
+
* . A NEST `PropertyNameAttribute`
429
+
* . Ask the serializer if the property has a verbatim value, e.g. it has a `JsonPropertyAttribute` if using {nuget}/NEST.JsonNetSerializer[`JsonNetSerializer`]
430
+
* . See if the `MemberInfo` has a `DataMemberAttribute` applied
431
+
* . Pass the `MemberInfo` to the `DefaultFieldNameInferrer`, which by default will camel case the `Name` property
431
432
*
432
433
* The following example class will demonstrate this precedence
433
434
*/
@@ -457,7 +458,8 @@ class Precedence
457
458
}
458
459
459
460
/**
460
-
* Here we create a custom serializer that renames any property named `AskSerializer` to `ask`
461
+
* We'll create a custom `IPropertyMappingProvider` that renames any property named `AskSerializer` to `ask`.
462
+
* and hook it up when creating the Connection Settings in the following section.
0 commit comments