2010-08-23 86 views
0

我兩個表,檔案和ProfileCategoryPLINQO主鍵和索引問題

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

ProfileCategory 
CategoryId 
ProfileId 

當我PLINGO生成的代碼,我得到下面的錯誤

操作「==」不能應用於操作數類型'int?'和'System.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

+0

你檢查,看看外鍵ProfileCategory.ProfileId引用Profile.ProfileId? – StuartLC 2010-08-23 20:41:28

+0

是的。我檢查了dbml文件,並刪除並重新創建了數據庫中的外鍵關係。 – Mantisimo 2010-08-23 21:03:42

回答

0

你檢查,以確保這是不是已經定格在PLINQO每晚構建輪廓snipet?您可以發佈這兩個表的架構(或發送給CodeSmith支持)。

感謝 -Blake Niemyjski

+0

只是做了這個,並沒有工作。我試着在我當前的項目上運行這個項目,並且我也在失敗時生成了一個新項目。我看了一下Entity.Generated.cst,它似乎將單獨的PK和IX混淆爲多對多的關係。 – Mantisimo 2010-08-24 06:54:21

+0

我將添加上面的模式。謝謝 – Mantisimo 2010-08-24 07:09:48

+0

你好, 你可以在哪裏添加模式? 謝謝 -Blake Niemyjski – 2010-08-31 12:44:18