ProfileId INT IX
UserId UNIQUEIDENTIFIER PK (For one-to-one mapping with aspnet_membership)
CompanyName
Description
ProfileCategory
CategoryId
ProfileId
나는 다음과 같은 오류가
을 두 개의 테이블, 프로필 및 ProfileCategory을받을 것연산자 '=='는 피연산자에 적용 할 수 없습니다
'int?'유형의 및 'System.Guid' 연산자 '=='은 'int'유형의 피연산자에 적용 할 수 없습니다. 및
[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);
}
그래서 생성 된 코드는 내가 직접 할 수있는 인덱스 및 기본 키
을 비교하려는 것 같다 ..
내가 생성 된 코드로 뛰어 다음과 같은 '는 System.Guid' 코드를 변경하지만 중생에 따라 코드가 변경됩니다.
왜 이런 일이 일어나는 지 알고 계십니까?
덕분에 여기
는<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>
당신이 외래 키 ProfileCategory.ProfileId이 Profile.ProfileId를 참조 있는지 확인해 봤어? – StuartLC
예. 나는 dbml 파일을 체크하고 데이터베이스에서 외래 키 관계를 삭제하고 다시 만들었다. – Mantisimo