我在下面的课程中得到了错误Duplicate mapping to column 'CustomerID' in class 'xCustomers'
,但我不知道我做错了什么。
Public Class xCustomers
Inherits XPBaseObject
Public Sub New(ByVal session As Session)
MyBase.New(session)
End Sub
<Key(True), Persistent("CustomerID")> Private _CustomerID As Integer = -1
Public Property CustomerID() As Integer
Get
Return _CustomerID
End Get
Set(ByVal value As Integer)
SetPropertyValue(Of Integer)("CustomerID", _CustomerID, value)
End Set
End Property
End Class
这是C#版本
public class xCustomers : XPBaseObject
{
public xCustomers(Session session) : base(session)
{
}
[Key(true), Persistent("CustomerID")]
private int _CustomerID = -1;
public int CustomerID {
get { return _CustomerID; }
set { SetPropertyValue<int>("CustomerID", _CustomerID, value); }
}
}
有什么想法吗?
答案 0 :(得分:1)
你应该在public int CustomerID之前添加Attribute [Key(true),Persistent(“CustomerID”)],而不是私有int _CustomerID。