Data Provider for .NET Guide (v11)

コード例

次のコードは、SSDL モデルの一例です。

<?xml version="1.0" encoding="utf-8"?> 
<Schema Namespace="EntityModel.Store" Alias="Self" xmlns="http://
schemas.microsoft.com/ado/2006/04/edm/ssdl" 
        Provider=Pervasive.Data.SqlClient" 
        ProviderManifestToken="PSQL"> 
   <EntityContainer Name="SampleStoreContainer"> 
      <EntitySet Name="Connection_Statistics" 
EntityType="EntityModel.Store.Connection_Statistics" /> 
      <EntitySet Name="Status" EntityType="EntityModel.Store.Status" /> 
   </EntityContainer> 
   <Function Name="RetrieveStatistics" Aggregate="false" BuiltIn="false" 
NiladicFunction="false" IsComposable="false" 
ParameterTypeSemantics="AllowImplicitConversion" 
StoreFunctionName="&quot;Psql_Connection_RetrieveStatistics&quot;" /> 
   <Function Name="EnableStatistics" Aggregate="false" BuiltIn="false" 
NiladicFunction="false" IsComposable="false" 
ParameterTypeSemantics="AllowImplicitConversion" 
StoreFunctionName="&quot;Psql_Connection_EnableStatistics&quot;" /> 
   <Function Name="EnableStatistics" Aggregate="false" BuiltIn="false" 
NiladicFunction="false" IsComposable="false" 
ParameterTypeSemantics="AllowImplicitConversion" 
StoreFunctionName="&quot;Psql_Connection_EnableStatistics&quot;" /> 
   <Function Name="ResetStatistics" Aggregate="false" BuiltIn="false" 
NiladicFunction="false" IsComposable="false" 
ParameterTypeSemantics="AllowImplicitConversion" 
StoreFunctionName="&quot;Psql_Connection_ResetStatistics&quot;" /> 
   </Function> 
   <EntityType Name="Connection_Statistics"> 
      <Key> 
         <PropertyRef Name="Id" /> 
      </Key> 
      <Property Name="SocketReadTime" Type="double" Nullable="false" /> 
      <Property Name="MaxSocketReadTime" Type="double" Nullable="false" /> 
      <Property Name="SocketReads" Type="bigint" Nullable="false" /> 
      <Property Name="BytesReceived" Type="bigint" Nullable="false" /> 
      <Property Name="MaxBytesPerSocketRead" Type="bigint" Nullable="false" /> 
      <Property Name="SocketWriteTime" Type="double" Nullable="false" /> 
      <Property Name="MaxSocketWriteTime" Type="double" Nullable="false" /> 
      <Property Name="SocketWrites" Type="bigint" Nullable="false" /> 
      <Property Name="BytesSent" Type="bigint" Nullable="false" /> 
      <Property Name="MaxBytesPerSocketWrite" Type="bigint" Nullable="false" /> 
      <Property Name="TimeToDisposeOfUnreadRows" Type="double" Nullable="false" /> 
      <Property Name="SocketReadsToDisposeUnreadRows" Type="bigint" Nullable="false" 
/> 
      <Property Name="BytesRecvToDisposeUnreadRows" Type="bigint" Nullable="false" /> 
      <Property Name="IDUCount" Type="bigint" Nullable="false" /> 
      <Property Name="SelectCount" Type="bigint" Nullable="false" /> 
      <Property Name="StoredProcedureCount" Type="bigint" Nullable="false" /> 
      <Property Name="DDLCount" Type="bigint" Nullable="false" /> 
      <Property Name="PacketsReceived" Type="bigint" Nullable="false" /> 
      <Property Name="PacketsSent" Type="bigint" Nullable="false" /> 
      <Property Name="ServerRoundTrips" Type="bigint" Nullable="false" /> 
      <Property Name="SelectRowsRead" Type="bigint" Nullable="false" /> 
      <Property Name="StatementCacheHits" Type="bigint" Nullable="false" /> 
      <Property Name="StatementCacheMisses" Type="bigint" Nullable="false" /> 
      <Property Name="StatementCacheReplaces" Type="bigint" Nullable="false" /> 
      <Property Name="StatementCacheTopHit1" Type="bigint" Nullable="false" /> 
      <Property Name="StatementCacheTopHit2" Type="bigint" Nullable="false" /> 
      <Property Name="StatementCacheTopHit3" Type="bigint" Nullable="false" /> 
      <Property Name="PacketsReceivedPerSocketRead" Type="double" Nullable="false" /> 
      <Property Name="BytesReceivedPerSocketRead" Type="double" Nullable="false" /> 
      <Property Name="PacketsSentPerSocketWrite" Type="double" Nullable="false" /> 
      <Property Name="BytesSentPerSocketWrite" Type="double" Nullable="false" /> 
      <Property Name="PacketsSentPerRoundTrip" Type="double" Nullable="false" /> 
      <Property Name="PacketsReceivedPerRoundTrip" Type="double" Nullable="false" /> 
      <Property Name="BytesSentPerRoundTrip" Type="double" Nullable="false" /> 
      <Property Name="BytesReceivedPerRoundTrip" Type="double" Nullable="false" /> 
      <Property Name="Id" Type="integer" Nullable="false" /> 
   </EntityType> 
   <EntityType Name="Status"> 
      <Key> 
         <PropertyRef Name="Id" /> 
      </Key> 
      <Property Name="ServerVersion" Type="varchar" MaxLength="127" Nullable="false" 
/> 
      <Property Name="Host" Type="varchar" MaxLength="127" Nullable="false" /> 
      <Property Name="Port" Type="integer" Nullable="false" /> 
      <Property Name="DatabaseName" Type="varchar" MaxLength="127" Nullable="false" /> 
      <Property Name="SessionId" Type="integer" Nullable="false" /> 
      <Property Name="StatisticsEnabled" Type="smallint_as_boolean" Nullable="false" 
/> 
      <Property Name="Id" Type="integer" Nullable="false" /> 
   </EntityType> 
</Schema> 

次のコードは、MSL モデルの一例です。

<?xml version="1.0" encoding="utf-8"?> 
<Mapping Space="C-S" xmlns="urn:schemas-microsoft-com:windows:storage:mapping:CS"> 
	<EntityContainerMapping 
    StorageEntityContainer="SampleStoreContainer" 
    CdmEntityContainer="SampleContainer"> 
      <EntitySetMapping Name="PsqlConnectionStatistics"> 
         <EntityTypeMapping TypeName="EntityModel.PsqlConnectionStatistics"> 
            <MappingFragment StoreEntitySet="Connection_Statistics"> 
               <ScalarProperty Name="SocketReadTime" ColumnName="SocketReadTime" /> 
               <ScalarProperty Name="MaxSocketReadTime" ColumnName="MaxSocketReadTime" 
/> 
               <ScalarProperty Name="SocketReads" ColumnName="SocketReads" /> 
               <ScalarProperty Name="BytesReceived" ColumnName="BytesReceived" /> 
               <ScalarProperty Name="MaxBytesPerSocketRead" 
ColumnName="MaxBytesPerSocketRead" /> 
               <ScalarProperty Name="SocketWriteTime" ColumnName="SocketWriteTime" /> 
               <ScalarProperty Name="MaxSocketWriteTime" 
ColumnName="MaxSocketWriteTime" /> 
               <ScalarProperty Name="SocketWrites" ColumnName="SocketWrites" /> 
               <ScalarProperty Name="BytesSent" ColumnName="BytesSent" /> 
               <ScalarProperty Name="MaxBytesPerSocketWrite" 
ColumnName="MaxBytesPerSocketWrite" /> 
               <ScalarProperty Name="TimeToDisposeOfUnreadRows" 
ColumnName="TimeToDisposeOfUnreadRows" /> 
               <ScalarProperty Name="SocketReadsToDisposeUnreadRows" 
ColumnName="SocketReadsToDisposeUnreadRows" /> 
               <ScalarProperty Name="BytesRecvToDisposeUnreadRows" 
ColumnName="BytesRecvToDisposeUnreadRows" /> 
               <ScalarProperty Name="IDUCount" ColumnName="IDUCount" /> 
               <ScalarProperty Name="SelectCount" ColumnName="SelectCount" /> 
               <ScalarProperty Name="StoredProcedureCount" 
ColumnName="StoredProcedureCount" /> 
               <ScalarProperty Name="DDLCount" ColumnName="DDLCount" /> 
               <ScalarProperty Name="PacketsReceived" ColumnName="PacketsReceived" /> 
               <ScalarProperty Name="PacketsSent" ColumnName="PacketsSent" /> 
               <ScalarProperty Name="ServerRoundTrips" ColumnName="ServerRoundTrips" /> 
               <ScalarProperty Name="SelectRowsRead" ColumnName="SelectRowsRead" /> 
               <ScalarProperty Name="StatementCacheHits" 
ColumnName="StatementCacheHits" /> 
               <ScalarProperty Name="StatementCacheMisses" 
ColumnName="StatementCacheMisses" /> 
               <ScalarProperty Name="StatementCacheReplaces" 
ColumnName="StatementCacheReplaces" /> 
               <ScalarProperty Name="StatementCacheTopHit1" 
ColumnName="StatementCacheTopHit1" /> 
               <ScalarProperty Name="StatementCacheTopHit2" 
ColumnName="StatementCacheTopHit2" /> 
               <ScalarProperty Name="StatementCacheTopHit3" 
ColumnName="StatementCacheTopHit3" /> 
               <ScalarProperty Name="PacketsReceivedPerSocketRead" 
ColumnName="PacketsReceivedPerSocketRead" /> 
               <ScalarProperty Name="BytesReceivedPerSocketRead" 
ColumnName="BytesReceivedPerSocketRead" /> 
               <ScalarProperty Name="PacketsSentPerSocketWrite" 
ColumnName="PacketsSentPerSocketWrite" /> 
               <ScalarProperty Name="BytesSentPerSocketWrite" 
ColumnName="BytesSentPerSocketWrite" /> 
               <ScalarProperty Name="PacketsSentPerRoundTrip" 
ColumnName="PacketsSentPerRoundTrip" /> 
               <ScalarProperty Name="PacketsReceivedPerRoundTrip" 
ColumnName="PacketsReceivedPerRoundTrip" /> 
               <ScalarProperty Name="BytesSentPerRoundTrip" 
ColumnName="BytesSentPerRoundTrip" /> 
               <ScalarProperty Name="BytesReceivedPerRoundTrip" 
ColumnName="BytesReceivedPerRoundTrip" /> 
               <ScalarProperty Name="Id" ColumnName="Id" /> 
            </MappingFragment> 
         </EntityTypeMapping> 
      </EntitySetMapping> 
      <EntitySetMapping Name="PsqlStatus"> 
         <EntityTypeMapping TypeName="EntityModel.PsqlStatus"> 
            <MappingFragment StoreEntitySet="Status"> 
               <ScalarProperty Name="ServerVersion" ColumnName="ServerVersion" /> 
               <ScalarProperty Name="Host" ColumnName="Host" /> 
               <ScalarProperty Name="Port" ColumnName="Port" /> 
               <ScalarProperty Name="DatabaseName" ColumnName="DatabaseName" /> 
               <ScalarProperty Name="SessionId" ColumnName="SessionId" /> 
               <ScalarProperty Name="StatisticsEnabled" ColumnName="StatisticsEnabled" 
/> 
               <ScalarProperty Name="Id" ColumnName="Id" /> 
            </MappingFragment> 
         </EntityTypeMapping> 
      </EntitySetMapping> 
      <FunctionImportMapping FunctionImportName="RetrieveStatistics" 
FunctionName="EntityModel.Store.RetrieveStatistics" /> 
      <FunctionImportMapping FunctionImportName="EnableStatistics" 
FunctionName="EntityModel.Store.EnableStatistics" /> 
      <FunctionImportMapping FunctionImportName="DisableStatistics" 
FunctionName="EntityModel.Store.DisableStatistics" /> 
      <FunctionImportMapping FunctionImportName="ResetStatistics" 
FunctionName="EntityModel.Store.ResetStatistics" /> 
      <FunctionImportMapping FunctionImportName="Reauthenticate" 
FunctionName="EntityModel.Store.Reauthenticate" /> 
   </EntityContainerMapping> 
</Mapping> 

モデルをさらに分解すると、CSDL モデルは、EDM で公開されている概念レイヤーで確立されます。

<?xml version="1.0" encoding="utf-8"?> 
<Schema Namespace="EntityModel" Alias="Self" xmlns="http://schemas.microsoft.com/
ado/2006/04/edm"> 
   <EntityContainer Name="SampleContainer"> 
      <EntitySet Name="PsqlConnectionStatistics" 
EntityType="EntityModel.PsqlConnectionStatistics" /> 
      <EntitySet Name="PsqlStatus" EntityType="EntityModel.PsqlStatus" /> 
      <FunctionImport Name="RetrieveStatistics" EntitySet="PsqlConnectionStatistics" 
ReturnType="Collection(EntityModel.PsqlConnectionStatistics)" /> 
      <FunctionImport Name="EnableStatistics" EntitySet="PsqlStatus" 
ReturnType="Collection(EntityModel.PsqlStatus)" /> 
      <FunctionImport Name="DisableStatistics" EntitySet="PsqlStatus" 
ReturnType="Collection(EntityModel.PsqlStatus)" /> 
      <FunctionImport Name="ResetStatistics" EntitySet="PsqlStatus" 
ReturnType="Collection(EntityModel.PsqlStatus)" /> 
      <FunctionImport Name="Reauthenticate" EntitySet="PsqlStatus" 
ReturnType="Collection(EntityModel.PsqlStatus)"> 
         <Parameter Name="CurrentUser" Type="String" /> 
         <Parameter Name="CurrentPassword" Type="String" /> 
         <Parameter Name="CurrentUserAffinityTimeout" Type="Int32" /> 
      </FunctionImport> 
   </EntityContainer> 
   <EntityType Name="PsqlConnectionStatistics"> 
      <Key> 
         <PropertyRef Name="Id" /> 
      </Key> 
      <Property Name="SocketReadTime" Type="Double" Nullable="false" /> 
      <Property Name="MaxSocketReadTime" Type="Double" Nullable="false" /> 
      <Property Name="SocketReads" Type="Int64" Nullable="false" /> 
      <Property Name="BytesReceived" Type="Int64" Nullable="false" /> 
      <Property Name="MaxBytesPerSocketRead" Type="Int64" Nullable="false" /> 
      <Property Name="SocketWriteTime" Type="Double" Nullable="false" /> 
      <Property Name="MaxSocketWriteTime" Type="Double" Nullable="false" /> 
      <Property Name="SocketWrites" Type="Int64" Nullable="false" /> 
      <Property Name="BytesSent" Type="Int64" Nullable="false" /> 
      <Property Name="MaxBytesPerSocketWrite" Type="Int64" Nullable="false" /> 
      <Property Name="TimeToDisposeOfUnreadRows" Type="Double" Nullable="false" /> 
      <Property Name="SocketReadsToDisposeUnreadRows" Type="Int64" Nullable="false" 
/> 
      <Property Name="BytesRecvToDisposeUnreadRows" Type="Int64" Nullable="false" /> 
      <Property Name="IDUCount" Type="Int64" Nullable="false" /> 
      <Property Name="SelectCount" Type="Int64" Nullable="false" /> 
      <Property Name="StoredProcedureCount" Type="Int64" Nullable="false" /> 
      <Property Name="DDLCount" Type="Int64" Nullable="false" /> 
      <Property Name="PacketsReceived" Type="Int64" Nullable="false" /> 
      <Property Name="PacketsSent" Type="Int64" Nullable="false" /> 
      <Property Name="ServerRoundTrips" Type="Int64" Nullable="false" /> 
      <Property Name="SelectRowsRead" Type="Int64" Nullable="false" /> 
      <Property Name="StatementCacheHits" Type="Int64" Nullable="false" /> 
      <Property Name="StatementCacheMisses" Type="Int64" Nullable="false" /> 
      <Property Name="StatementCacheReplaces" Type="Int64" Nullable="false" /> 
      <Property Name="StatementCacheTopHit1" Type="Int64" Nullable="false" /> 
      <Property Name="StatementCacheTopHit2" Type="Int64" Nullable="false" /> 
      <Property Name="StatementCacheTopHit3" Type="Int64" Nullable="false" /> 
      <Property Name="PacketsReceivedPerSocketRead" Type="Double" Nullable="false" /> 
      <Property Name="BytesReceivedPerSocketRead" Type="Double" Nullable="false" /> 
      <Property Name="PacketsSentPerSocketWrite" Type="Double" Nullable="false" /> 
      <Property Name="BytesSentPerSocketWrite" Type="Double" Nullable="false" /> 
      <Property Name="PacketsSentPerRoundTrip" Type="Double" Nullable="false" /> 
      <Property Name="PacketsReceivedPerRoundTrip" Type="Double" Nullable="false" /> 
      <Property Name="BytesSentPerRoundTrip" Type="Double" Nullable="false" /> 
      <Property Name="BytesReceivedPerRoundTrip" Type="Double" Nullable="false" /> 
      <Property Name="Id" Type="Int32" Nullable="false" /> 
   </EntityType> 
   <EntityType Name="PsqlStatus"> 
      <Key> 
         <PropertyRef Name="Id" /> 
      </Key> 
      <Property Name="ServerVersion" Type="String" Nullable="false" /> 
      <Property Name="Host" Type="String" Nullable="false" /> 
      <Property Name="Port" Type="Int32" Nullable="false" /> 
      <Property Name="DatabaseName" Type="String" Nullable="false" /> 
      <Property Name="SessionId" Type="Int32" Nullable="false" /> 
      <Property Name="StatisticsEnabled" Type="Boolean" Nullable="false" /> 
      <Property Name="Id" Type="Int32" Nullable="false" /> 
   </EntityType> 
</Schema> 
 

.edmx ファイルの使用

バルク ロード構成ファイル