InheritanceMappingAttribute 클래스

정의

LINQ to SQL 애플리케이션의 상속 계층 구조를 매핑합니다.

public ref class InheritanceMappingAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=false)]
public sealed class InheritanceMappingAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=true, Inherited=false)>]
type InheritanceMappingAttribute = class
    inherit Attribute
Public NotInheritable Class InheritanceMappingAttribute
Inherits Attribute
상속
InheritanceMappingAttribute
특성

예제

보여 주는이 예제 계층에 대 한 상속 매핑이 있는 매핑된 최상위 클래스 (Shape)는 추상 클래스입니다.

public enum ShapeType
{
    Square = 0, Circle = 1
}
[Table(Name = "Shape")]
[InheritanceMapping(Code = ShapeType.Square, Type = typeof(Square),
    IsDefault = true)]
[InheritanceMapping(Code = ShapeType.Circle, Type = typeof(Circle))]

abstract public class Shape
{
    [Column(IsDiscriminator = true)]
    public ShapeType ShapeType = 0;
}

public class Square : Shape
{
    [Column]
    public int Side = 0;
}
public class Circle : Shape
{
    [Column]
    public int Radius = 0;
}
Public Enum ShapeType As Integer
    Square = 0
    Circle = 1
End Enum

<Table(Name:="Shape")> _
<InheritanceMapping(Code:=ShapeType.Square, Type:=GetType(Square), _
    IsDefault:=True)> _
<InheritanceMapping(Code:=ShapeType.Circle, Type:=GetType(Circle))> _
Public MustInherit Class Shape
    <Column(IsDiscriminator:=True)> _
        Public ShapeType As ShapeType = 0
End Class

Public Class Square
    Inherits Shape
    <Column()> _
    Public Side As Integer = 0
End Class

Public Class Circle
    Inherits Shape
    <Column()> _
    Public Radius As Integer = 0
End Class

다음 예제에서는 매핑되지 않은 클래스의 포함 여부를 보여 줍니다. 계층 구조에서 어디에 매핑되지 않은 클래스를 넣을 수 있습니다.

// Unmapped and not queryable.
class A {  }

// Mapped and queryable.
[Table]
[InheritanceMapping(Code = "B", Type = typeof(B),
IsDefault = true)]
[InheritanceMapping(Code = "D", Type = typeof(D))]
class B: A {  }

// Unmapped and not queryable.
class C: B {  }

// Mapped and queryable.
class D: C {  }

// Unmapped and not queryable.
class E: D {  }
' Unmapped and not queryable.
Class A
End Class

' Mapped and queryable.
<Table()> _
<InheritanceMapping(Code:="B", Type:=GetType(B), _
IsDefault:=True)> _
<InheritanceMapping(Code:="D", Type:=GetType(D))> _
Class B
    Inherits A
End Class

' Unmapped and not queryable.
Class C
    Inherits B
End Class

' Mapped and queryable.
Class D
    Inherits C
End Class

' Unmapped and not queryable.
Class E
    Inherits D
End Class

설명

하나의 InheritanceMappingAttribute 매핑된 클래스 별로 지정 됩니다.

상속 계층 구조를 매핑할 때 다음 note:

  • 계층의 모든 클래스는 단일 테이블에 매핑해야 합니다.

  • 상속 계층 구조에 대 한 테이블을 계층의 최상위에 있는 매핑된 형식에 선언 되어야 합니다. 최상위 클래스에서 파생 된 클래스에서 테이블 또는 매핑 특성을 지정할 수 없습니다.

  • 계층 구조에서 인터페이스를 사용할 수 있지만 LINQ는 인터페이스를 매핑하지 않습니다.

  • 매핑된 클래스에만 쿼리할 수 있지만 클래스를 매핑할 경우 계층 구조에서 클래스를 건너뛸 수 있습니다.

올바른 구체화에 대 한 판별자 코드 값 고유 하 고 데이터베이스 값과 일치 해야 합니다. 정확히 일치 하지 않으면 (도 대/소문자 구분)으로 판별자 코드 값을 가진 행을 사용 하 여 클래스를 인스턴스화합니다 IsDefaulttrue합니다.

생성자

InheritanceMappingAttribute()

InheritanceMappingAttribute 클래스의 새 인스턴스를 초기화합니다.

속성

Code

매핑된 상속 계층 구조의 판별자 코드 값을 가져오거나 설정합니다.

IsDefault

판별자 값이 지정된 값과 일치하지 않는 경우 이 형식의 개체가 인스턴스화되는지 여부를 가져오거나 설정합니다.

Type

계층 구조에 있는 클래스의 형식을 가져오거나 설정합니다.

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 Attribute)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상