2009-06-18 3 views
2

EDM로 프로젝트를 작성했습니다. 누구든지 TPH 상속 트리의 엔티티에서 discriminator 열의 값을 가져 오는 방법을 알고 있습니까? 엔티티에 속성을 추가 할 수 없습니다. 가치를 얻는 다른 방법이 있습니까?엔티티 프레임 워크 엔터티에서 Discriminator 열의 값을 얻는 방법

감사합니다,
로이

+0

: 여기

는 오라클 데이터베이스에 대한 예입니다? –

+0

나는 질의 응답 (Question and Answers)의 계층 구조를 가지고 있으며, 답변 만이 같은 유형의 질문에만 관련 될 수 있습니다. – LPCRoy

답변

2

는 갱신 가능한 뷰를 suports DBMS에 대한 문제를 해결하는 간단한 방법이있다. 추가 판별 자 열이있는보기 또는 정의 쿼리를 만들면됩니다. 원래 열은 class 속성에 매핑되어야합니다. DBMS가 업데이트 가능한 뷰를 지원하지 않는 경우 쿼리 정의를 사용하고 삽입/업데이트/삭제 작업을 위해 저장 프로 시저를 매핑 할 수 있습니다. 당신이 그것을 왜 필요합니까

 
SQL: 
CREATE TABLE TEST.TPH_TABLE (
    ID NUMBER(9), 
    COLUMN_A VARCHAR2(20), 
    COLUMN_B VARCHAR2(20), 
    BASE_COLUMN VARCHAR2(20), 
    CONSTRAINT PK_TPH_TABLE PRIMARY KEY (ID) 
); 

EDMX: 
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx"> 
    <!-- EF Runtime content --> 
    <edmx:Runtime> 
    <!-- SSDL content --> 
    <edmx:StorageModels> 
     <Schema Namespace="Model1.Store" Alias="Self" Provider="Devart.Data.Oracle" ProviderManifestToken="ORA" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl"> 
     <EntityContainer Name="Model1StoreContainer"> 
      <EntitySet Name="TPH_TABLE" EntityType="Model1.Store.TPH_TABLE" > 
      <DefiningQuery> 
       SELECT ID, BASE_COLUMN, COLUMN_A, COLUMN_B, 
        CASE WHEN COLUMN_A IS NOT NULL THEN '1' ELSE NULL END AS "IS_TABLE_A" 
       FROM TPH_TABLE 
      </DefiningQuery> 
      </EntitySet> 
     </EntityContainer> 
     <EntityType Name="TPH_TABLE"> 
      <Key> 
      <PropertyRef Name="ID" /> 
      </Key> 
      <Property Name="ID" Type="int" Nullable="false" /> 
      <Property Name="BASE_COLUMN" Type="VARCHAR2" MaxLength="20" /> 
      <Property Name="COLUMN_A" Type="VARCHAR2" MaxLength="20" /> 
      <Property Name="COLUMN_B" Type="VARCHAR2" MaxLength="20" /> 
      <Property Name="IS_TABLE_A" Type="VARCHAR2" MaxLength="1" /> 
     </EntityType> 
     </Schema> 
    </edmx:StorageModels> 
    <!-- CSDL content --> 
    <edmx:ConceptualModels> 
     <Schema Namespace="Model1" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2006/04/edm"> 
     <EntityContainer Name="Entities"> 
      <EntitySet Name="TPH_TABLE" EntityType="Model1.TPH_TABLE" /> 
     </EntityContainer> 
     <EntityType Name="TPH_TABLE" Abstract="true"> 
      <Key> 
      <PropertyRef Name="ID" /> 
      </Key> 
      <Property Name="ID" Type="Int32" Nullable="false" /> 
      <Property Name="BASE_COLUMN" Type="String" MaxLength="20" Unicode="true" FixedLength="false" /> 
     </EntityType> 
     <EntityType Name="TABLE_A" BaseType="Model1.TPH_TABLE" > 
      <Property Name="COLUMN_A" Type="String" Nullable="true" /> 
     </EntityType> 
     <EntityType Name="TABLE_B" BaseType="Model1.TPH_TABLE" > 
      <Property Name="COLUMN_B" Type="String" Nullable="true" /> 
     </EntityType> 
     </Schema> 
    </edmx:ConceptualModels> 
    <!-- C-S mapping content --> 
    <edmx:Mappings> 
     <Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"> 
     <EntityContainerMapping StorageEntityContainer="Model1StoreContainer" CdmEntityContainer="Entities"> 
      <EntitySetMapping Name="TPH_TABLE"> 
      <EntityTypeMapping TypeName="Model1.TABLE_A"> 
       <MappingFragment StoreEntitySet="TPH_TABLE"> 
       <ScalarProperty Name="ID" ColumnName="ID" /> 
       <ScalarProperty Name="BASE_COLUMN" ColumnName="BASE_COLUMN" /> 
       <ScalarProperty Name="COLUMN_A" ColumnName="COLUMN_A" /> 
       <Condition ColumnName="IS_TABLE_A" Value="1" /> 
       </MappingFragment> 
      </EntityTypeMapping> 
      <EntityTypeMapping TypeName="Model1.TABLE_B"> 
       <MappingFragment StoreEntitySet="TPH_TABLE"> 
       <ScalarProperty Name="ID" ColumnName="ID" /> 
       <ScalarProperty Name="BASE_COLUMN" ColumnName="BASE_COLUMN" /> 
       <ScalarProperty Name="COLUMN_B" ColumnName="COLUMN_B" /> 
       <Condition ColumnName="IS_TABLE_A" IsNull="true" /> 
       </MappingFragment> 
      </EntityTypeMapping> 
      </EntitySetMapping> 
     </EntityContainerMapping> 
     </Mapping> 
    </edmx:Mappings> 
    </edmx:Runtime> 
    <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) --> 
    <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2007/06/edmx"> 
    <edmx:Connection> 
     <DesignerInfoPropertySet> 
     <DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" /> 
     </DesignerInfoPropertySet> 
    </edmx:Connection> 
    <edmx:Options> 
     <DesignerInfoPropertySet> 
     <DesignerProperty Name="ValidateOnBuild" Value="true" /> 
     </DesignerInfoPropertySet> 
    </edmx:Options> 
    <!-- Diagram content (shape and connector positions) --> 
    <edmx:Diagrams> 
     <Diagram Name="Model4"> 
     <EntityTypeShape EntityType="Model1.TPH_TABLE" Width="1.5" PointX="3" PointY="0.5" Height="1.2636116536458335" IsExpanded="true" /> 
     <EntityTypeShape EntityType="Model1.TABLE_A" Width="1.5" PointX="1.75" PointY="2.75" Height="1.099264322916667" /> 
     <EntityTypeShape EntityType="Model1.TABLE_B" Width="1.5" PointX="4.25" PointY="2.75" Height="1.099264322916667" /> 
     <InheritanceConnector EntityType="Model1.TABLE_B" ManuallyRouted="false"> 
      <ConnectorPoint PointX="4.375" PointY="1.7636116536458335" /> 
      <ConnectorPoint PointX="4.375" PointY="2.75" /> 
      </InheritanceConnector> 
     <InheritanceConnector EntityType="Model1.TABLE_A" ManuallyRouted="false"> 
      <ConnectorPoint PointX="3.125" PointY="1.7636116536458335" /> 
      <ConnectorPoint PointX="3.125" PointY="2.75" /> 
      </InheritanceConnector></Diagram></edmx:Diagrams> 
    </edmx:Designer> 
</edmx:Edmx>