Joined: Tue Jul 25, 2006 11:06 pm Posts: 2
|
I have Class Parent and Child like this:
public class Child
{
public Child()
{
}
public virtual string Name
{
get { return name; }
set { name = value; }
}
public virtual int childId
{
get { return childid; }
set { childId = value; }
}
public virtual Parent Parent
{
get { return parent; }
set { parent = value; }
}
private int childid;
private string name;
private Parent parent;
}
public class Parent
{
public Parent()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public virtual int ParentId
{
get { return parentId; }
set { parentId = value; }
}
public virtual string Name
{
get { return name; }
set { name = value; }
}
public virtual IDictionary Childs
{
get { return childs; }
set { childs = value; }
}
private int parentId;
private string name;
private IDictionary childs = new Hashtable();
}
my code in page:
Parent parent = new Parent();
parent.Name = "test parent";
Child child = new Child();
child.Name = "test child";
child.Parent = parent;
parent.Childs.Add( child, child );
session.Save(parent);
session.Flush();
errorInfor:
System.InvalidCastException: 指定的转换无效。
how to solve this ?
|
|