Skip to content

Commit 8db508e

Browse files
committed
Merge Type and definition processing into a single method
1 parent 4855cbf commit 8db508e

File tree

2 files changed

+151
-153
lines changed

2 files changed

+151
-153
lines changed

dotnet/src/InternalUtilities/connectors/Memory/MongoDB/MongoModelBuilder.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,14 @@ internal class MongoModelBuilder() : CollectionModelBuilder(s_validationOptions)
2727
UsesExternalSerializer = true,
2828
};
2929

30-
[RequiresUnreferencedCode("Traverses the CLR type's properties with reflection, so not compatible with trimming")]
31-
protected override void ProcessTypeProperties(Type type, VectorStoreCollectionDefinition? definition)
30+
protected override void ProcessProperty(PropertyInfo? clrProperty, VectorStoreProperty? definitionProperty, Type? type)
3231
{
33-
base.ProcessTypeProperties(type, definition);
32+
base.ProcessProperty(clrProperty, definitionProperty, type);
3433

35-
foreach (var property in this.Properties)
34+
if (clrProperty?.GetCustomAttribute<BsonElementAttribute>() is { } bsonElementAttribute
35+
&& this.PropertyMap.TryGetValue(clrProperty.Name, out var property))
3636
{
37-
if (property.PropertyInfo?.GetCustomAttribute<BsonElementAttribute>() is { } bsonElementAttribute)
38-
{
39-
property.StorageName = bsonElementAttribute.ElementName;
40-
}
37+
property.StorageName = bsonElementAttribute.ElementName;
4138
}
4239
}
4340

0 commit comments

Comments
 (0)