求问Activerecord中数据读取问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 02:30:01
我根据别人的代码写的一个用Activerecord来持久化数据库的测试程序,可以往数据库中添加新项,却不能读取里面的数据。在编译时会显示ActiveRecordException。请各位哥哥帮我看看吧,谢谢。

//实体类
...
...
[PrimaryKey(PrimaryKeyType.Identity, "LongonID")]
public int Id
{
get
{
return _id;
}
set
{
_id = value;
}
}

[Property("LogonName")]
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}

[Property("Password")]
public string Password
{
get
{
return _password;
}

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
isTrue = false; //这里的问题应该s
user = UserOne.Find(1); //异常抛出点
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (!isTrue)
{
TextBox1.Text = user.Name.ToString();
TextBox2.Text = user.Password.ToString();
TextBox3.Text = user.Address.ToString();
TextBox4.Text = user.LastLogon.ToString();
isTrue = true;
}
else
{
TextBox1.Text = TextBox2.Text = TextBox3.Text = TextBox4.Text = "";
isTrue = false;
}
}
}