Comments (4)
That is correct behavior. Default schema tried last to allow user to override it using more specific schema.
from linq2db.
The problem only is the codes never gets to the default schema because of the following code in the MappingSchema class:
/// Gets attributes of specified type, associated with specified type.
/// </summary>
/// <typeparam name="T">Mapping attribute type (must inherit <see cref="MappingAttribute"/>).</typeparam>
/// <param name="type">Attributes owner type.</param>
/// <returns>Attributes of specified type.</returns>
private T[] GetAllAttributes<T>(Type type)
where T : MappingAttribute
{
return Schemas[0].MetadataReader?.GetAttributes<T>(type) ?? Array<T>.Empty;
}
/// <summary>
/// Gets attributes of specified type, associated with specified type member.
/// </summary>
/// <typeparam name="T">Mapping attribute type (must inherit <see cref="MappingAttribute"/>).</typeparam>
/// <param name="type">Member's owner type.</param>
/// <param name="memberInfo">Attributes owner member.</param>
/// <returns>Attributes of specified type.</returns>
private T[] GetAllAttributes<T>(Type type, MemberInfo memberInfo)
where T : MappingAttribute
{
return Schemas[0].MetadataReader?.GetAttributes<T>(type, memberInfo) ?? Array<T>.Empty;
}
With using Schema[0] it always takes the first of the list. What we see is that AddSqlServer on the DataOptions adds two extra schemas to the beginning of this list. Forcing the default schema to the last position of the schema list.
from linq2db.
Schemas[0].MetadataReader
is not just first metadata reader actually, but instance of https://github.com/linq2db/linq2db/blob/master/Source/LinqToDB/Metadata/MetadataReader.cs which aggregates access to all metadata readers in MappingSchema
on schema creation or when you add additional provider to current schema. If you add provider to child schema after current schema created - it will not affect current schema:
var ms = new MappingSchema();
// ms use metadata providers from Default schema
ms.AddMetadataReader(provider1);
// ms now use provider1 and providers from Default schema
// with provider1 having higher priority
DefaultSchema.AddMetadataReader(provider2);
// default schema now have provider2 with highest priority alongside with other providers it already had
// but ms schema still works with provider1 and old set of providers, copied from default schema during
// ms schema creation
from linq2db.
Oke, I did mis the part that the default will be used when no more specific schema is defined. But, when the code that is in the original post is used, our own provider is not being called. The breakpoints in the getattributes are not being hit.
Imo this is because the default schema with our own provider is in the last place of the schema list. And with the code that is now in the library only the first schema will be used.
What is also a bit weird is that there will be two extra schema's without them being created knowingly.
from linq2db.
Related Issues (20)
- Read some json values, Common Language Runtime detected an invalid program. HOT 5
- update documentation to show how to use fluent mapping HOT 1
- Enum Array insert/update
- Migrate table functions scaffold to `TableFromExpression`
- List of improvements for Preview 2 HOT 1
- Global Filters with Joins cause stack overflow when query cache is enabled
- Difference in resulting SQL when using LoadWith and LeftJoin HOT 1
- StringAggregate with GroupBy on SQL Server HOT 2
- DateTime not correctly handled in insert and update
- Query cache makes query filter Func irrelevant after first execution HOT 4
- Fluent mapper + expression based association fails when using generic IQueryable extension. Works when just accessing in Linq HOT 1
- Npgsql.PostgresException: '23505: duplicate key value violates unique constraint
- Unable to delete file SQLite.Interop.dll, access to the path '' is denied when trying to clean multi targeting (net472 and netstandard2.0) project HOT 1
- SQL-Server GroupBy-Query with nullable String-Key fails to create working SQL when used in an IN-Query instead of old EXISTS-Behaviour HOT 2
- Parameterization in PostgreSQL queries HOT 1
- Assign extra properties to the object leads to query parsing fail HOT 3
- Adding AsExpandable() from LinqKit with extra predicate leads to parsing fail HOT 1
- Wrong SQL is generated for sub-query HOT 2
- Power only accept doubles
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linq2db.