Groups
Groups
Sign in
Groups
Groups
NBear Google Group
Conversations
About
Send feedback
Help
关于自连接
0 views
Skip to first unread message
菌哥
unread,
Dec 8, 2006, 8:55:54 AM
12/8/06
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to NBear Google Group
一个表,比如
ID,ParentID
我现在让顶级ID的ParentID为空,请问Save如何做?
问题1:在定义的时候如果定义成 int?
ID,这样生成的实体类是错误的
问题2:既然不能定义int?,那么ID怎么能够为空呢?
Teddy
unread,
Dec 8, 2006, 9:26:19 AM
12/8/06
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nbear...@googlegroups.com
ID可以定义成int,ParentID定义成int?就行了!
菌哥
unread,
Dec 8, 2006, 8:22:24 PM
12/8/06
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to NBear Google Group
不是说了吗,是自连接,应该比如是这样的:
public interface Node : Entity //部门
{
[PrimaryKey] //自身主键
int ID { get; set;}
[FkReverseQuery]
Node ParentID { get; set; }
}
这时ParentID是类型还是Node,既然是Node,
那么其ID又是主键,怎么可能设置为int?呢
Teddy
unread,
Dec 8, 2006, 9:48:52 PM
12/8/06
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nbear...@googlegroups.com
我说的就是自连接!!
下面这样定义:
public interface Node : Entity //部门
{
[PrimaryKey] //自身主键
int ID { get; set;}
[FkReverseQuery]
Node ParentID { get; set; }
}
Parent对应的ParentID默认就是int?的。你不给它赋值他就是null。
Teddy
Reply all
Reply to author
Forward
0 new messages