0

这适用于 Firebird .NET Provider 2.6.5:

using (var context = new SetupContext())
{
    _maxApplicationID = context.Application.Max(a => (int?)a.ID) ?? 0;
}

表映射:

<!-- SSDL content -->
<edmx:StorageModels>
  <Schema Namespace="Model1.Store" Alias="Self" Provider="FirebirdSql.Data.FirebirdClient" ProviderManifestToken="2.5" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">
    <EntityContainer Name="Model1StoreContainer">
      <EntitySet Name="APPLICATION" EntityType="Model1.Store.APPLICATION" store:Type="Tables" Schema="Firebird" />
    </EntityContainer>
    <EntityType Name="APPLICATION">
      <Key>
        <PropertyRef Name="ID" />
      </Key>
      <Property Name="ID" Type="int" Nullable="false" />
      <Property Name="NAME" Type="varchar" Nullable="false" MaxLength="50" />
      <Property Name="DISPLAY_TEXT" Type="varchar" MaxLength="255" />
      <Property Name="ARGUMENTS" Type="varchar" MaxLength="255" />
      <Property Name="PATH" Type="varchar" MaxLength="255" />
      <Property Name="TYPE" Type="char" MaxLength="1" />
    </EntityType>
  </Schema>
</edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
  <Schema Namespace="Model1" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">
    <EntityContainer Name="Entities" annotation:LazyLoadingEnabled="true">
      <EntitySet Name="Application" EntityType="Model1.Application" />
    </EntityContainer>
    <EntityType Name="Application">
      <Key>
        <PropertyRef Name="ID" />
      </Key>
      <Property Name="ID" Type="Int32" Nullable="false" />
      <Property Name="Name" Type="String" Nullable="false" MaxLength="50" Unicode="true" FixedLength="false" />
      <Property Name="DisplayText" Type="String" MaxLength="255" Unicode="true" FixedLength="false" />
      <Property Name="Arguments" Type="String" MaxLength="255" Unicode="true" FixedLength="false" />
      <Property Name="Path" Type="String" MaxLength="255" Unicode="true" FixedLength="false" />
      <Property Name="Type" Type="String" MaxLength="1" Unicode="true" FixedLength="true" />
    </EntityType>
  </Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
  <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs">
    <EntityContainerMapping StorageEntityContainer="Model1StoreContainer" CdmEntityContainer="Entities">
      <EntitySetMapping Name="Application"><EntityTypeMapping TypeName="Model1.Application"><MappingFragment StoreEntitySet="APPLICATION">
        <ScalarProperty Name="ID" ColumnName="ID" />
        <ScalarProperty Name="Name" ColumnName="NAME" />
        <ScalarProperty Name="DisplayText" ColumnName="DISPLAY_TEXT" />
        <ScalarProperty Name="Arguments" ColumnName="ARGUMENTS" />
        <ScalarProperty Name="Path" ColumnName="PATH" />
        <ScalarProperty Name="Type" ColumnName="TYPE" />
      </MappingFragment></EntityTypeMapping></EntitySetMapping>
    </EntityContainerMapping>
  </Mapping>
</edmx:Mappings>

现在我已经升级到 Firebird .NET Provider 2.7.5 版本,我收到一个 ArgumentNullException 说“值不能为空。参数名称:键”。

这是 2.7.5 中的更改行为还是更新出了问题。如果这是一种改变的行为:如何获得一列的最大值?

4

1 回答 1

1

如果按照 Mark Rotteveel 的建议完成。这是 firebird 错误数据库中的票据链接:http: //tracker.firebirdsql.org/browse/DNET-429

于 2012-05-09T08:05:29.690 回答