33// See the LICENSE file in the project root for more information.
44
55using System ;
6- using System . Collections . Generic ;
76using System . Linq . Expressions ;
8- using System . Text . Json ;
97
108namespace Elastic . Clients . Elasticsearch
119{
1210 public class ClrTypeMapping
1311 {
1412 /// <summary>
15- /// Initializes a new instance of <see cref="ClrTypeMapping" />
13+ /// Initializes a new instance of <see cref="ClrTypeMapping" />.
1614 /// </summary>
1715 public ClrTypeMapping ( Type type ) => ClrType = type ;
1816
19- /// <inheritdoc />
17+ /// <summary>
18+ /// The CLR type the mapping relates to.
19+ /// </summary>
2020 public Type ClrType { get ; }
2121
22- /// <inheritdoc />
22+ /// <summary>
23+ /// The property for the given <see cref="ClrType" /> to resolve IDs from.
24+ /// </summary>
2325 public string IdPropertyName { get ; set ; }
2426
25- /// <inheritdoc />
27+ /// <summary>
28+ /// The default Elasticsearch index name for the given <see cref="ClrType" />.
29+ /// </summary>
2630 public string IndexName { get ; set ; }
2731
28- /// <inheritdoc />
32+ /// <summary>
33+ /// The relation name for the given <see cref="ClrType" /> to resolve to.
34+ /// </summary>
2935 public string RelationName { get ; set ; }
3036
31- /// <inheritdoc />
37+ /// <summary>
38+ /// Disables ID inference for the given <see cref="ClrType"/>.
39+ /// By default, the _id value for a document is inferred from a property named Id,
40+ /// or from the property named by <see cref="IdPropertyName"/>, if set.
41+ /// </summary>
3242 public bool DisableIdInference { get ; set ; }
3343 }
3444
35- public sealed class ClrTypeMapping < TDocument > : ClrTypeMapping where TDocument : class
45+ public sealed class ClrTypeMapping < TDocument > : ClrTypeMapping
3646 {
3747 public ClrTypeMapping ( ) : base ( typeof ( TDocument ) ) { }
3848
39- /// <inheritdoc />
49+ /// <summary>
50+ /// Set a default Id property on CLR type <typeparamref name="TDocument" /> that NEST will evaluate
51+ /// </summary>
4052 public Expression < Func < TDocument , object > > IdProperty { get ; set ; }
4153
42- /// <inheritdoc />
43- public IList < IClrPropertyMapping < TDocument > > Properties { get ; set ; }
44-
45- /// <inheritdoc />
54+ /// <summary>
55+ /// Provide a default routing parameter lookup based on <typeparamref name="TDocument" />
56+ /// </summary>
4657 public Expression < Func < TDocument , object > > RoutingProperty { get ; set ; }
4758 }
4859
@@ -54,34 +65,26 @@ public sealed class ClrTypeMappingDescriptor : DescriptorBase<ClrTypeMappingDesc
5465 internal string _idProperty ;
5566 internal bool _disableIdInference ;
5667
57- // TODO - XML Comments
58-
5968 /// <summary>
6069 /// Instantiates a new instance of <see cref="ClrTypeMappingDescriptor" />
6170 /// </summary>
6271 /// <param name="type">The CLR type to map</param>
6372 public ClrTypeMappingDescriptor ( Type type ) => _clrType = type ;
6473
65- ///// <inheritdoc cref="IClrTypeMapping .IndexName"/>
74+ /// <inheritdoc cref="ClrTypeMapping .IndexName"/>
6675 public ClrTypeMappingDescriptor IndexName ( string indexName ) => Assign ( indexName , ( a , v ) => a . _indexName = v ) ;
6776
68- ///// <inheritdoc cref="IClrTypeMapping .RelationName"/>
77+ /// <inheritdoc cref="ClrTypeMapping .RelationName"/>
6978 public ClrTypeMappingDescriptor RelationName ( string relationName ) => Assign ( relationName , ( a , v ) => a . _relationName = v ) ;
7079
71- /// <summary>
72- /// The property for the given <see cref="Type" /> to resolve IDs from.
73- /// </summary>
80+ /// <inheritdoc cref="ClrTypeMapping{T}.IdProperty"/>
7481 public ClrTypeMappingDescriptor IdProperty ( string idProperty ) => Assign ( idProperty , ( a , v ) => a . _idProperty = v ) ;
7582
76- ///// <inheritdoc cref="IClrTypeMapping .DisableIdInference"/>
83+ /// <inheritdoc cref="ClrTypeMapping .DisableIdInference"/>
7784 public ClrTypeMappingDescriptor DisableIdInference ( bool disable = true ) => Assign ( disable , ( a , v ) => a . _disableIdInference = v ) ;
78-
79- protected override void Serialize ( Utf8JsonWriter writer , JsonSerializerOptions options , IElasticsearchClientSettings settings ) => throw new NotImplementedException ( ) ;
8085 }
8186
82- public sealed class ClrTypeMappingDescriptor < TDocument >
83- : DescriptorBase < ClrTypeMappingDescriptor < TDocument > >
84- where TDocument : class
87+ public sealed class ClrTypeMappingDescriptor < TDocument > : DescriptorBase < ClrTypeMappingDescriptor < TDocument > >
8588 {
8689 internal Type _clrType = typeof ( TDocument ) ;
8790 internal string _indexName ;
@@ -91,47 +94,24 @@ public sealed class ClrTypeMappingDescriptor<TDocument>
9194
9295 internal Expression < Func < TDocument , object > > _idPropertyExpression ;
9396 internal Expression < Func < TDocument , object > > _routingPropertyExpression ;
94- internal IList < IClrPropertyMapping < TDocument > > _properties = new List < IClrPropertyMapping < TDocument > > ( ) ;
9597
96- /// <summary>
97- /// The default Elasticsearch index name for <typeparamref name="TDocument" />
98- /// </summary>
98+ /// <inheritdoc cref="ClrTypeMapping.IndexName"/>
9999 public ClrTypeMappingDescriptor < TDocument > IndexName ( string indexName ) => Assign ( indexName , ( a , v ) => a . _indexName = v ) ;
100100
101- /// <summary>
102- /// The relation name for <typeparamref name="TDocument" /> to resolve to.
103- /// </summary>
101+ /// <inheritdoc cref="ClrTypeMapping.RelationName"/>
104102 public ClrTypeMappingDescriptor < TDocument > RelationName ( string relationName ) => Assign ( relationName , ( a , v ) => a . _relationName = v ) ;
105103
106- /// <summary>
107- /// Set a default Id property on CLR type <typeparamref name="TDocument" /> that Elastic.Clients.Elasticsearch will evaluate
108- /// </summary>
104+ /// <inheritdoc cref="ClrTypeMapping{T}.IdProperty"/>
109105 public ClrTypeMappingDescriptor < TDocument > IdProperty ( Expression < Func < TDocument , object > > property ) => Assign ( property , ( a , v ) => a . _idPropertyExpression = v ) ;
110106
111- /// <summary>
112- /// Set a default Id property on CLR type <typeparamref name="TDocument" /> that Elastic.Clients.Elasticsearch will evaluate
113- /// </summary>
107+ /// <inheritdoc cref="ClrTypeMapping{T}.IdProperty"/>
114108 public ClrTypeMappingDescriptor < TDocument > IdProperty ( string property ) => Assign ( property , ( a , v ) => a . _idProperty = v ) ;
115109
116- /// <summary> Provide a default routing parameter lookup based on <typeparamref name="TDocument" /> </summary >
110+ /// <inheritdoc cref="ClrTypeMapping{T}.RoutingProperty"/ >
117111 public ClrTypeMappingDescriptor < TDocument > RoutingProperty ( Expression < Func < TDocument , object > > property ) =>
118112 Assign ( property , ( a , v ) => a . _routingPropertyExpression = v ) ;
119113
120- /// <summary>
121- /// Ignore <paramref name="property" /> on CLR type <typeparamref name="TDocument" />
122- /// </summary>
123- public ClrTypeMappingDescriptor < TDocument > Ignore ( Expression < Func < TDocument , object > > property ) =>
124- Assign ( property , ( a , v ) => a . _properties . Add ( new IgnoreClrPropertyMapping < TDocument > ( v ) ) ) ;
125-
126- /// <summary>
127- /// Rename <paramref name="property" /> on CLR type <typeparamref name="TDocument" />
128- /// </summary>
129- public ClrTypeMappingDescriptor < TDocument > PropertyName ( Expression < Func < TDocument , object > > property , string newName ) =>
130- Assign ( new RenameClrPropertyMapping < TDocument > ( property , newName ) , ( a , v ) => a . _properties . Add ( v ) ) ;
131-
132- ///// <inheritdoc cref="IClrTypeMapping.DisableIdInference"/>
114+ /// <inheritdoc cref="ClrTypeMapping.DisableIdInference"/>
133115 public ClrTypeMappingDescriptor < TDocument > DisableIdInference ( bool disable = true ) => Assign ( disable , ( a , v ) => a . _disableIdInference = v ) ;
134-
135- protected override void Serialize ( Utf8JsonWriter writer , JsonSerializerOptions options , IElasticsearchClientSettings settings ) => throw new NotImplementedException ( ) ;
136116 }
137117}
0 commit comments