What are the ODataConventionModelBuilder conventions?

There are many examples of using ODataConventionModelBuilder with simple, far-fetched models, often just one class.

But there is nothing that actually explains what conventions are; how to encode a model that matches the convention. There is no official documentation.

So what is the convention?

+5
source share
2 answers

From what I have seen so far, the conventions are those used by the Entity Framework, unlike any new ones for OData. Please correct me if I am wrong.

More information on agreements with codes is given below, but there is still a lot of things in Julie Lerman’s book, I can’t find an exhaustive list of them on the Internet.

http://blogs.msdn.com/b/efdesign/archive/2010/06/01/conventions-for-code-first.aspx

Update

The EF conventions are hooked up, and each convention is represented by a class encapsulating behavior, and these classes are listed here:

http://msdn.microsoft.com/en-us/library/system.data.entity.modelconfiguration.conventions(v=vs.113).aspx

However, this does not help which ones are applicable or are used by ODataConventionModelBuilder , if any.

  • AssociationInverseDiscoveryConvention . Provides an agreement for discovering navigation properties that should be inverse to each other when there is only one pair of navigation properties between related types.
  • AttributeToColumnAnnotationConvention is a general purpose class for Code First conventions that reads attributes from .NET properties and generates column annotations based on these attributes.
  • AttributeToTableAnnotationConvention is a general purpose class for Code First conventions that reads attributes from .NET types and generates table annotations based on these attributes.
  • ColumnAttributeConvention . Represents the convention for handling ColumnAttribute instances found in properties in a model.
  • ColumnOrderingConvention . Represents the convention for applying column ordering specified using the ColumnAttribute or the DbModelBuilder API.
  • ColumnOrderingConventionStrict . - The Convention on the Use of Column Ordering Defined Using the ColumnAttribute or DbModelBuilder API. This convention produces if a duplicate customized column order is found.
  • ComplexTypeAttributeConvention . Represents the convention for handling instances of ComplexTypeAttribute found in types in a model.
  • ComplexTypeDiscoveryConvention . Represents an agreement for configuring a type as a complex type, if it does not have a primary key, there is no base type, and no navigation properties.
  • ConcurrencyCheckAttributeConvention . Represents the convention for handling instances of ConcurrencyCheckAttributefound by properties in the model.
  • Convention An agreement that does not override the configuration.
  • DatabaseGeneratedAttributeConvention . Represents the convention for processing instances of DatabaseGeneratedAttribute found in properties in a model.
  • DecimalPropertyConvention - A convention for setting precision to 18 and scaling to 2 for decimal properties.
  • DeclaredPropertyOrderingConvention . Represents a convention that allows you to first transfer the properties of a primary key.
  • ForeignKeyAssociationMultiplicityConvention . Represents an agreement on the distinction between optional and required relationships based on the CLR uncertainty of a foreign key property.
  • ForeignKeyDiscoveryConvention . Represents the base class for conventions that discover foreign key properties.
  • ForeignKeyIndexConvention - is an agreement on the introduction of indexes for foreign keys.
  • ForeignKeyNavigationPropertyAttributeConvention . Represents the convention for handling ForeignKeyAttribute instances found in the navigation properties in the model.
  • ForeignKeyPrimitivePropertyAttributeConvention . Represents a convention for handling ForeignKeyAttribute instances found in foreign key properties in a model.
  • IdKeyDiscoveryConvention . - Convention for the discovery of primary key properties. Recognized naming patterns in order of priority: 1. "Identifier" 2. [type name] Id. The definition of the primary key is not case sensitive.
  • IndexAttributeConvention - an agreement on finding IndexAttribute attributes by properties and generating annotations of the indexIndexAnnotation column in the model.
  • InversePropertyAttributeConvention . Represents the convention for handling InversePropertyAttribute instances found in properties in a model.
  • KeyAttributeConvention - A convention for handling KeyAttribute instances found by properties in the model.
  • KeyDiscoveryConvention . Represents the base class for conventions that discover primary key properties.
  • ManyToManyCascadeDeleteConvention . - The Convention on the Addition of Cascading Deletion to the Table of Compounds from both tables, participating in many ways
  • MappingInheritedPropertiesSupportConvention . A convention to ensure invalid / unsupported matching is not created when inherited properties are displayed.
  • MaxLengthAttributeConvention . Represents the convention for handling MaxLengthAttribute instances found in properties in a model.
  • NavigationPropertyNameForeignKeyDiscoveryConvention . - A convention for detecting foreign key properties whose names are a combination of the name of the dependent navigation function and the primary key name (s) of the primary type.
  • NotMappedPropertyAttributeConvention . Represents a convention for handling NotMappedAttribute instances found in properties in a model.
  • NotMappedTypeAttributeConvention . Represents a convention for handling NotMappedAttribute instances found in types in a model.
  • OneToManyCascadeDeleteConvention . Provides an agreement to enable cascading deletion for any necessary relationships.
  • OneToOneConstraintIntroductionConvention . Provides an agreement on setting the primary key (s) of the dependent type of an object as a foreign key (s) in a one: one ratio.
  • PluralizingEntitySetNameConvention . It is an agreement to set the name of a collection of objects as a plural version of an entity type name.
  • PluralizingTableNameConvention . Represents the convention that a table name is a pluralized version of an entity type name.
  • PrimaryKeyNameForeignKeyDiscoveryConvention . - Convention on the search for foreign key properties whose names correspond to the name (s) of the primary key of the main type.
  • PrimitivePropertyAttributeConfigurationConvention is the base class for conventions that process CLR attributes found in primitive properties in the model.
  • PropertyAttributeConfigurationConvention is the base class for conventions handling CLR attributes found in type properties in the model.
  • PropertyMaxLengthConvention . Represents the convention for setting the maximum length for properties whose type supports phase faces. The default value is 128.
  • RequiredNavigationPropertyAttributeConvention . - A convention for handling RequiredAttribute instances found in model navigation properties.
  • RequiredPrimitivePropertyAttributeConvention . Represents a convention for handling RequiredAttribute instances found in primitive properties in a model.
  • SqlCePropertyMaxLengthConvention . Represents an agreement to set a default maximum length of 4000 for properties whose type supports edge lengths when SqlCe is a provider.
  • StoreGeneratedIdentityKeyConvention - This is an agreement on setting up whole primary keys for identification.
  • StringLengthAttributeConvention . Represents the convention for handling StringLengthAttribute instances found in properties in a model.
  • TableAttributeConvention . Represents the convention for handling instances of a table attribute found in types in a model.
  • TimestampAttributeConvention . Represents a convention for handling instances of TimestampAttribute found in properties in a model.
  • TypeAttributeConfigurationConvention is the base class for conventions handling CLR attributes found in the model.
  • TypeNameForeignKeyDiscoveryConvention . - A convention for detecting properties of a foreign key whose names are a combination of the name of the primary type and the name (s) of the primary key of the primary key.
+4
source

The best explanation I know of is here

Routing Conventions in ASP.NET Web API 2 Odata

NB is Odata 3, not odata 4

0
source

Source: https://habr.com/ru/post/1210496/


All Articles