J'ai deux tables, Profil et ProfileCategoryPLINQO primaire problème clé et l'indice
ProfileId INT IX
UserId UNIQUEIDENTIFIER PK (For one-to-one mapping with aspnet_membership)
CompanyName
Description
ProfileCategory
CategoryId
ProfileId
Quand je produis le code avec PLINGO je reçois des erreurs suivantes
opérateur « == » ne peut pas être appliqué aux opérandes de type 'int?' et 'System.Guid' L'opérateur '==' ne peut pas être appliqué à des opérandes de type 'int?' et « System.GUID »
Je plongeai le code généré et les éléments suivants ..
[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);
}
Ainsi, le code généré semble vouloir comparer l'index et la clé primaire
je peux manuellement modifier le code, mais à la régénération, il sera modifié.
Est-ce que quelqu'un sait pourquoi cela se produit?
Merci
Voici le profil snipet de la 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>
Avez-vous vérifié pour voir que la référence ProfileCategory.ProfileId clé étrangère Profile.ProfileId? – StuartLC
Ouais c'est le cas. J'ai vérifié dans le fichier dbml et j'ai supprimé et recréé la relation de clé étrangère dans la base de données. – Mantisimo