Replies: 2 comments 1 reply
-
You can create new mapping schema (once) and register |
Beta Was this translation helpful? Give feedback.
-
The quickest way is to add the default mappingschema to the DataOptions.
However, you could argue that this is not the cleanest way to go. Imo it is weird that when looking for metadatareaders you always go for Schema[0] which is not necessarily the default schema. Also it is weird that the default schema is not the first in the schema list. |
Beta Was this translation helpful? Give feedback.
-
I am upgrading after a long time from 3.3.0 to 5.4.1 and I have a case where i need to add a custom meta data reader. According to the documentation this is achieved with the following:
LinqToDB.Mapping.MappingSchema.Default.AddMetadataReader(new LinqToDbProvider(DbContextOptions.IsSite1 ? typeof(ColumnSite1Attribute) : typeof(ColumnSite2Attribute)));
However, when i try to get data out of my database this reader is is not used. When running it trough while debugging two other schemas were added to the schema list. This results in that my custom schema is last in the line. With the following piece of code in get the getattributes functions it will always get the first item out of the list:
Schemas[0].MetadataReader?.GetAttributes<T>(type, memberInfo) ?? Array<T>.Empty;
Did i read the documentation wrong or is there something else i need to do?
Beta Was this translation helpful? Give feedback.
All reactions