EntityTypeConfiguration<TEntityType>.HasRequired<TTargetEntity>-Methode
[Diese Seite bezieht sich auf Entity Framework Version 6. Die neueste Version ist als 'Entity Framework' NuGet-Paket verfügbar. Weitere Informationen zu Entity Framework finden Sie unter msdn.com/data/ef.]
Konfiguriert eine erforderliche Beziehung von diesem Entitätstyp. Instanzen dieses Entitätstyps können nur in der Datenbank gespeichert werden, wenn diese Beziehung angegeben wurde. Der Fremdschlüssel in der Datenbank kann nicht NULL sein.
Namespace: System.Data.Entity.ModelConfiguration
Assembly: EntityFramework (in EntityFramework.dll)
Syntax
'Declaration
<SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")> _
<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")> _
Public Function HasRequired(Of TTargetEntity As Class) ( _
navigationPropertyExpression As Expression(Of Func(Of TEntityType, TTargetEntity)) _
) As RequiredNavigationPropertyConfiguration(Of TEntityType, TTargetEntity)
'Usage
Dim instance As EntityTypeConfiguration
Dim navigationPropertyExpression As Expression(Of Func(Of TEntityType, TTargetEntity))
Dim returnValue As RequiredNavigationPropertyConfiguration(Of TEntityType, TTargetEntity)
returnValue = instance.HasRequired(navigationPropertyExpression)
[SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
public RequiredNavigationPropertyConfiguration<TEntityType, TTargetEntity> HasRequired<TTargetEntity>(
Expression<Func<TEntityType, TTargetEntity>> navigationPropertyExpression
)
where TTargetEntity : class
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1011:ConsiderPassingBaseTypesAsParameters")]
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1006:DoNotNestGenericTypesInMemberSignatures")]
public:
generic<typename TTargetEntity>
where TTargetEntity : ref class
RequiredNavigationPropertyConfiguration<TEntityType, TTargetEntity>^ HasRequired(
Expression<Func<TEntityType, TTargetEntity>^>^ navigationPropertyExpression
)
[<SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")>]
[<SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")>]
member HasRequired :
navigationPropertyExpression:Expression<Func<'TEntityType, 'TTargetEntity>> -> RequiredNavigationPropertyConfiguration<'TEntityType, 'TTargetEntity> when 'TTargetEntity : not struct
JScript does not support generic types and methods.
Typparameter
- TTargetEntity
Der Typ der Entität am anderen Ende der Beziehung.
Parameter
- navigationPropertyExpression
Typ: System.Linq.Expressions.Expression<Func<TEntityType, TTargetEntity>>
Ein Lambdaausdruck, der die Navigationseigenschaft für die Beziehung darstellt. C#: t => t.MyProperty VB.Net: Function(t) t.MyProperty
Rückgabewert
Typ: System.Data.Entity.ModelConfiguration.Configuration.RequiredNavigationPropertyConfiguration<TEntityType, TTargetEntity>
Ein Konfigurationsobjekt, das für die weitere Konfiguration der Beziehung verwendet werden kann.