PLINQO主键与索引问题

发布于 2024-09-15 20:03:12 字数 4038 浏览 6 评论 0原文

我有两个表,Profile 和 ProfileCategory

ProfileId INT IX
UserId UNIQUEIDENTIFIER PK (For one-to-one mapping with aspnet_membership)
CompanyName
Description

ProfileCategory
CategoryId
ProfileId

当我使用 PLINGO 生成代码时,出现以下错误

Operator '=='无法应用于类型为'int?'的操作数和“系统.Guid” 运算符“==”不能应用于“int?”类型的操作数和“System.Guid”

我深入研究了生成的代码和以下内容。

    [System.Diagnostics.DebuggerNonUserCode]
    [System.CodeDom.Compiler.GeneratedCode("CodeSmith", "5.0.0.0")]
    private void OnProfileList1Remove(Profile entity)
    {
        SendPropertyChanging(null);
        var profileCategory = ProfileCategoryList.FirstOrDefault(c => c.CategoryId == CategoryId
            && c.ProfileId == entity.UserId);
        ProfileCategoryList.Remove( profileCategory);
        SendPropertyChanged(null);
    }

所以生成的代码似乎想要比较索引和主键

我可以手动更改代码,但在重新生成时它将被更改回来。

有谁知道为什么会发生这种情况?

谢谢

这是来自 dbml

    <Table Name="dbo.Profile" Member="Profile">
        <Type Name="Profile">
          <Column Name="UserId" Storage="_userId" Type="System.Guid" DbType="uniqueidentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
          <Column Name="ProfileId" Storage="_profileId" Type="System.Int32" DbType="int NOT NULL IDENTITY" CanBeNull="false" />
          <Column Name="CompanyName" Storage="_companyName" Type="System.String" DbType="nvarchar(250) NOT NULL" CanBeNull="false" />
          <Column Name="Description" Storage="_description" Type="System.String" DbType="varchar(MAX)" CanBeNull="true" />
          <Column Name="Services" Storage="_services" Type="System.Xml.Linq.XElement" DbType="xml" CanBeNull="true" UpdateCheck="Never" />
          <Column Name="ContactDetails" Storage="_contactDetails" Type="System.Xml.Linq.XElement" DbType="xml" CanBeNull="true" UpdateCheck="Never" />
          <Column Name="Attributes" Storage="_attributes" Type="System.Xml.Linq.XElement" DbType="xml" CanBeNull="true" UpdateCheck="Never" />
          <Column Name="StateId" Storage="_stateId" Type="System.Int32" DbType="int NOT NULL" CanBeNull="false" />
          <Column Name="Views" Storage="_views" Type="System.Int32" DbType="int NOT NULL" CanBeNull="false" />
          <Association Name="User_Profile" Member="User" Storage="_user" ThisKey="UserId" Type="User" IsForeignKey="true" DeleteRule="CASCADE" />
          <Association Name="Profile_ProfileAddress" Member="ProfileAddressList" Storage="_profileAddressList" OtherKey="UserId" Type="ProfileAddress" DeleteOnNull="false" />
          <Association Name="Profile_Review" Member="ReviewList" Storage="_reviewList" ThisKey="ProfileId" OtherKey="ProfileId" Type="Review" DeleteOnNull="false" />
          <Association Name="Profile_ProfileCategory" Member="ProfileCategoryList" Storage="_profileCategoryList" ThisKey="ProfileId" OtherKey="ProfileId" Type="ProfileCategory" />
        </Type>
 </Table>
 <Table Name="dbo.ProfileCategory" Member="ProfileCategory">
    <Type Name="ProfileCategory">
      <Column Name="ProfileCategoryId" Storage="_profileCategoryId" Type="System.Int32" DbType="int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="ProfileId" Storage="_profileId" Type="System.Int32" DbType="int" CanBeNull="true" />
      <Column Name="CategoryId" Storage="_categoryId" Type="System.Int32" DbType="int NOT NULL" CanBeNull="false" />
      <Association Name="Category_ProfileCategory" Member="Category" Storage="_category" ThisKey="CategoryId" Type="Category" IsForeignKey="true" />
      <Association Name="Profile_ProfileCategory" Member="Profile" Storage="_profile" ThisKey="ProfileId" OtherKey="ProfileId" Type="Profile" IsForeignKey="true" DeleteRule="CASCADE" />
    </Type>
  </Table>

alt text的配置文件片段

I've two tables, Profile and ProfileCategory

ProfileId INT IX
UserId UNIQUEIDENTIFIER PK (For one-to-one mapping with aspnet_membership)
CompanyName
Description

ProfileCategory
CategoryId
ProfileId

When I generate the code with PLINGO I get following errors

Operator '==' cannot be applied to operands of type 'int?' and 'System.Guid'
Operator '==' cannot be applied to operands of type 'int?' and 'System.Guid'

I dived into the generated code and the following..

    [System.Diagnostics.DebuggerNonUserCode]
    [System.CodeDom.Compiler.GeneratedCode("CodeSmith", "5.0.0.0")]
    private void OnProfileList1Remove(Profile entity)
    {
        SendPropertyChanging(null);
        var profileCategory = ProfileCategoryList.FirstOrDefault(c => c.CategoryId == CategoryId
            && c.ProfileId == entity.UserId);
        ProfileCategoryList.Remove( profileCategory);
        SendPropertyChanged(null);
    }

So the generated code seems to want to compare the index and the primary key

I can manually alter the code but on regeneration it will be altered back.

Does anyone know why this is happening?

Thanks

Here is the profile snipet from the dbml

    <Table Name="dbo.Profile" Member="Profile">
        <Type Name="Profile">
          <Column Name="UserId" Storage="_userId" Type="System.Guid" DbType="uniqueidentifier NOT NULL" IsPrimaryKey="true" CanBeNull="false" />
          <Column Name="ProfileId" Storage="_profileId" Type="System.Int32" DbType="int NOT NULL IDENTITY" CanBeNull="false" />
          <Column Name="CompanyName" Storage="_companyName" Type="System.String" DbType="nvarchar(250) NOT NULL" CanBeNull="false" />
          <Column Name="Description" Storage="_description" Type="System.String" DbType="varchar(MAX)" CanBeNull="true" />
          <Column Name="Services" Storage="_services" Type="System.Xml.Linq.XElement" DbType="xml" CanBeNull="true" UpdateCheck="Never" />
          <Column Name="ContactDetails" Storage="_contactDetails" Type="System.Xml.Linq.XElement" DbType="xml" CanBeNull="true" UpdateCheck="Never" />
          <Column Name="Attributes" Storage="_attributes" Type="System.Xml.Linq.XElement" DbType="xml" CanBeNull="true" UpdateCheck="Never" />
          <Column Name="StateId" Storage="_stateId" Type="System.Int32" DbType="int NOT NULL" CanBeNull="false" />
          <Column Name="Views" Storage="_views" Type="System.Int32" DbType="int NOT NULL" CanBeNull="false" />
          <Association Name="User_Profile" Member="User" Storage="_user" ThisKey="UserId" Type="User" IsForeignKey="true" DeleteRule="CASCADE" />
          <Association Name="Profile_ProfileAddress" Member="ProfileAddressList" Storage="_profileAddressList" OtherKey="UserId" Type="ProfileAddress" DeleteOnNull="false" />
          <Association Name="Profile_Review" Member="ReviewList" Storage="_reviewList" ThisKey="ProfileId" OtherKey="ProfileId" Type="Review" DeleteOnNull="false" />
          <Association Name="Profile_ProfileCategory" Member="ProfileCategoryList" Storage="_profileCategoryList" ThisKey="ProfileId" OtherKey="ProfileId" Type="ProfileCategory" />
        </Type>
 </Table>
 <Table Name="dbo.ProfileCategory" Member="ProfileCategory">
    <Type Name="ProfileCategory">
      <Column Name="ProfileCategoryId" Storage="_profileCategoryId" Type="System.Int32" DbType="int NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" />
      <Column Name="ProfileId" Storage="_profileId" Type="System.Int32" DbType="int" CanBeNull="true" />
      <Column Name="CategoryId" Storage="_categoryId" Type="System.Int32" DbType="int NOT NULL" CanBeNull="false" />
      <Association Name="Category_ProfileCategory" Member="Category" Storage="_category" ThisKey="CategoryId" Type="Category" IsForeignKey="true" />
      <Association Name="Profile_ProfileCategory" Member="Profile" Storage="_profile" ThisKey="ProfileId" OtherKey="ProfileId" Type="Profile" IsForeignKey="true" DeleteRule="CASCADE" />
    </Type>
  </Table>

alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

丿*梦醉红颜 2024-09-22 20:03:12

您是否检查过以确保该问题尚未在 PLINQO 的夜间版本中修复?您能否发布这两个表的架构(或发送给 CodeSmith 支持人员)。

谢谢
——布莱克·尼米斯基

Have you checked to make sure this wasn't already fixed in a nightly build of PLINQO? Could you please post the schema (or send to CodeSmith support) for these two tables.

Thanks
-Blake Niemyjski

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文