The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 14:02:32 +0800
Local: Wed, Nov 15 2006 1:02 am
Subject: 发布NBearV3.2.2 Beta
下载地址:
https://sourceforge.net/project/showfiles.php?group_id=165914
本次更新内容应该比较令人值得期待:
1、更全面的自增长主键支持。现在即使是有继承关系的实体,也可以设置自增长主键了。
2、自动Guid主键支持。原来,如果使用Guid作主键,必须手动设置新建实体的主键值。在新版本中,如果使用Guid主键,如果没有为主键设置值,NBea r会在Save时自动为它生成一个值。因此,您将能和int自增长字段类似使用Guid主键的实体。
3、自动设置关联属性。原来的版本中,如果Profile是User的属性,但是,Profile包含一个UserID外键属性,则保存user前需要手动设置 Profile的UserID为当前user的ID;在新版本中,这样的关联属性无需再手动设置,凡是设置到User的对象,save user时,这些关联属性会自动从user中获取。
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"勇敢的心" <my... @163.com>
Date: Tue, 14 Nov 2006 22:19:03 -0800
Local: Wed, Nov 15 2006 1:19 am
Subject: Re: 发布NBearV3.2.2 Beta
字段属性实在太多了啊,好头晕。
PrimaryKey,FriendKey,
PkQuery,FkQuery,
PkReverseQuery,FkReverseQuery,
ManyToManyQuery,
CustomQuery
能不能考虑简化一下!看了你的说明文档,
可还是不清楚为什么要这么多属性
才能描述清楚。
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 14:26:18 +0800
Local: Wed, Nov 15 2006 1:26 am
Subject: Re: 发布NBearV3.2.2 Beta
无需一个个死记硬背的,下面的文章中讲解了所有常见关联关系的设置,你可以看到,其实是很容易理解的。你要什么关联关系,参照示例代码设置就行,也可以参考SD K文档对这些属性的解释(虽然目前的SDK文档内容还不是很完备)。
http://www.cnblogs.com/teddyma/archive/2006/11/09/554823.html
Teddy
On 11/15/06, 勇敢的心 <my... @163.com> wrote:
> 字段属性实在太多了啊,好头晕。 > PrimaryKey,FriendKey, > PkQuery,FkQuery, > PkReverseQuery,FkReverseQuery, > ManyToManyQuery, > CustomQuery > 能不能考虑简化一下!看了你的说明文档, > 可还是不清楚为什么要这么多属性 > 才能描述清楚。
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"勇敢的心" <my... @163.com>
Date: Tue, 14 Nov 2006 22:34:22 -0800
Local: Wed, Nov 15 2006 1:34 am
Subject: Re: 发布NBearV3.2.2 Beta
可不可以多表直接在一个类里关联,如果我现在两张表
部门表(deptID,deptName),用户表(deptID,UserName)
我现在一个Table里想显示deptName,UserName要怎么做!
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 14:42:37 +0800
Local: Wed, Nov 15 2006 1:42 am
Subject: Re: 发布NBearV3.2.2 Beta
其实如果你设置好两者的关联,那么,就可以通过一个部门实例的属性访问相关人员信息。这才是ORM。
另外,如果你想要逻辑上的视图,而不是OR的Mapping,那么,就该建数据库视图来描述。否则,在一个Table里显示deptName,UserName 代表的算是哪个O呢?
Teddy
On 11/15/06, 勇敢的心 <my... @163.com> wrote:
> 可不可以多表直接在一个类里关联,如果我现在两张表 > 部门表(deptID,deptName),用户表(deptID,UserName) > 我现在一个Table里想显示deptName,UserName要怎么做!
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 11:17:21 -0000
Local: Wed, Nov 15 2006 6:17 am
Subject: Re: 发布NBearV3.2.2 Beta
"Teddy 写道: "
> 1、更全面的自增长主键支持。现在即使是有继承关系的实体,也可以设置自增长主键了。
只设置get吗?还是get,set都要?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 19:31:24 +0800
Local: Wed, Nov 15 2006 6:31 am
Subject: Re: 发布NBearV3.2.2 Beta
只设置get。例如:
[PrimaryKey] int ID { get; }
另外,v3.2.2中又发现了一个其他方面的错误,已经在v3.2.3中修复。
如果正在使用v3.2.2,请下载最新的v3.2.3。
Teddy
On 11/15/06, feng... @gmail.com <feng... @gmail.com> wrote:
> "Teddy 写道: > " > > 1、更全面的自增长主键支持。现在即使是有继承关系的实体,也可以设置自增长主键了。
> 只设置get吗?还是get,set都要?
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 11:59:16 -0000
Local: Wed, Nov 15 2006 6:59 am
Subject: Re: 发布NBearV3.2.2 Beta
无法将 NULL 值插入列 'ID',表
'mk2.dbo.User';该列不允许空值。INSERT 失败。
语句已终止。
有错误啊,定义如下 public interface User : Entity { [PrimaryKey] int ID { get; }
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 20:02:35 +0800
Local: Wed, Nov 15 2006 7:02 am
Subject: Re: 发布NBearV3.2.2 Beta
最好给出更详细的代码信息。根据错误提示,很明显,你似乎往ID字段保存Null值。
On 11/15/06, feng... @gmail.com <feng... @gmail.com> wrote:
> 无法将 NULL 值插入列 'ID',表 > 'mk2.dbo.User';该列不允许空值。INSERT 失败。 > 语句已终止。
> 有错误啊,定义如下 > public interface User : Entity > { > [PrimaryKey] > int ID > { > get; > }
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 12:06:35 -0000
Local: Wed, Nov 15 2006 7:06 am
Subject: Re: 发布NBearV3.2.2 Beta
Save代码如下:
public User CreatNewUser() { WriteLine("Create a new user and set property values."); Entities.User user = new Entities.User(); UserName name = new UserName(); name.FirstName = "MK2"; name.LastName = "Feng";
UserProfile profile = new UserProfile(); //profile.UserID = user.ID; profile.LastIP = "00000"; profile.Content = "mk2profile"; user.Profile = profile;
user.Name = name; user.Birthday = DateTime.Now; user.Email = "feng... @gmail.com"; user.LogOnCount = 0; user.LogOnDate = DateTime.Now; user.LogOnName = "fengmk2"; user.No = "333"; user.PassAnswer = "ddd"; user.PassQuestion = "kkk"; user.Password = "222"; user.Status = UserStatus.Availate;
return user; }
protected void btnNewUser_Click(object sender, EventArgs e) { Entities.User user = CreatNewUser(); gateway.Save<Entities.User>(user); WriteLine("The found user:"); WriteLine(SerializationManager.Serialize(user)); }
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 12:11:12 -0000
Local: Wed, Nov 15 2006 7:11 am
Subject: Re: 发布NBearV3.2.2 Beta
运行时的Insert语句:
Text INSERT INTO [User] ( [Name], [Email], [Status], [LogOnName], [Password], [PassQuestion], [PassAnswer], [No], [Sex], [Birthday], [CreateDate], [LogOnDate], [LogOnCount] ) VALUES ( @Name, @Email, @Status, @LogOnName, @Password, @PassQuestion, @PassAnswer, @No, @Sex, @Birthday, @CreateDate, @LogOnDate, @LogOnCount ); SELECT SCOPE_IDENTITY() Parameters: @Name[String] = <?xml version="1.0" encoding="utf-16"?> <UserName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd="http://www.w3.org/2001/XMLSchema "> <FirstName>MK2</FirstName> <LastName>Feng</LastName> </UserName> @Email[String] = feng... @gmail.com @Status[Int32] = Availate @LogOnName[String] = fengmk2 @Password[String] = 222 @PassQuestion[String] = kkk @PassAnswer[String] = ddd @No[String] = 333 @Sex[String] = @Birthday[DateTime] = 2006-11-15 20:08:28 @CreateDate[String] = @LogOnDate[DateTime] = 2006-11-15 20:08:28 @LogOnCount[Int32] = 0
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 20:20:16 +0800
Local: Wed, Nov 15 2006 7:20 am
Subject: Re: 发布NBearV3.2.2 Beta
从代码来看,我怀疑你的数据库脚本不一定正确。你有没有用新的entity design生成新数据库脚本呢?
另外要使用自增长字段的话,需要将User.ID设为只读,例如:
[PrimaryKey] int ID { get; }
如果数据库中User.ID是自增长字段,绝对不会报NUll插入ID的错误的。就算是ID的默认值,那也只会是0。
Teddy
On 11/15/06, feng... @gmail.com <feng... @gmail.com> wrote:
> 运行时的Insert语句:
> Text INSERT INTO [User] ( [Name], [Email], [Status], [LogOnName], > [Password], [PassQuestion], [PassAnswer], [No], [Sex], [Birthday], > [CreateDate], [LogOnDate], [LogOnCount] ) VALUES ( @Name, @Email, > @Status, @LogOnName, @Password, @PassQuestion, @PassAnswer, @No, @Sex, > @Birthday, @CreateDate, @LogOnDate, @LogOnCount ); SELECT > SCOPE_IDENTITY() > Parameters: > @Name[String] = <?xml version="1.0" encoding="utf-16"?> > <UserName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " > xmlns:xsd="http://www.w3.org/2001/XMLSchema "> > <FirstName>MK2</FirstName> > <LastName>Feng</LastName> > </UserName> > @Email[String] = feng... @gmail.com > @Status[Int32] = Availate > @LogOnName[String] = fengmk2 > @Password[String] = 222 > @PassQuestion[String] = kkk > @PassAnswer[String] = ddd > @No[String] = 333 > @Sex[String] = > @Birthday[DateTime] = 2006-11-15 20:08:28 > @CreateDate[String] = > @LogOnDate[DateTime] = 2006-11-15 20:08:28 > @LogOnCount[Int32] = 0
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 12:25:05 -0000
Local: Wed, Nov 15 2006 7:25 am
Subject: Re: 发布NBearV3.2.2 Beta
用V3.2.3 生成的
生成的关于User的这段数据库脚本:
CREATE TABLE [dbo].[User] ( [ID] int IDENTITY (1, 1) NOT NULL, [Name] ntext NULL, [Email] nvarchar(50) NULL, [Status] int NULL, [LogOnName] nvarchar(50) NULL, [Password] nvarchar(50) NULL, [PassQuestion] nvarchar(100) NULL, [PassAnswer] nvarchar(100) NULL, [No] nvarchar(30) NULL, [Sex] nvarchar(10) NULL, [Birthday] datetime NULL, [CreateDate] datetime NULL, [LogOnDate] datetime NULL, [LogOnCount] int NULL ) ON [PRIMARY] GO
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 20:32:58 +0800
Local: Wed, Nov 15 2006 7:32 am
Subject: Re: 发布NBearV3.2.2 Beta
我按照你的数据库脚本和sql语句测试,完全正常啊~~
你检查一下数据库中的User表的ID字段的当前类型目前是不是真的是identity。
可以试试直接在 查询分析器 里对你的数据库执行下面的脚本:
INSERT INTO [User] ( [Name], [Email], [Status], [LogOnName], [Password], [PassQuestion], [PassAnswer], [No], [Sex], [Birthday], [CreateDate], [LogOnDate], [LogOnCount] ) VALUES ( '<?xml version="1.0" encoding="utf-16"?> <UserName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd="http://www.w3.org/2001/XMLSchema "> <FirstName>MK2</FirstName> <LastName>Feng</LastName> </UserName>', 'feng... @gmail.com', 0, 'fengmk2', '222', 'sss', 'qqq', '333', null, '2006-11-15 20:08:28', '2006-11-15 20:08:28', '2006-11-15 20:08:28', 1 ); SELECT SCOPE_IDENTITY()
看看会不会报错。
我这里是正常的。
On 11/15/06, feng... @gmail.com <feng... @gmail.com> wrote:
> 用V3.2.3 生成的 > 生成的关于User的这段数据库脚本:
> CREATE TABLE [dbo].[User] ( > [ID] int IDENTITY (1, 1) NOT NULL, > [Name] ntext NULL, > [Email] nvarchar(50) NULL, > [Status] int NULL, > [LogOnName] nvarchar(50) NULL, > [Password] nvarchar(50) NULL, > [PassQuestion] nvarchar(100) NULL, > [PassAnswer] nvarchar(100) NULL, > [No] nvarchar(30) NULL, > [Sex] nvarchar(10) NULL, > [Birthday] datetime NULL, > [CreateDate] datetime NULL, > [LogOnDate] datetime NULL, > [LogOnCount] int NULL > ) ON [PRIMARY] > GO
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 12:40:21 -0000
Local: Wed, Nov 15 2006 7:40 am
Subject: Re: 发布NBearV3.2.2 Beta
我在查询分析器测试也是成功的,就是在Web上不行``````昏迷中```````
我先去试试IoC示例中的,那个好像也是使用int自增的```
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 12:51:54 -0000
Local: Wed, Nov 15 2006 7:51 am
Subject: Re: 发布NBearV3.2.2 Beta
晕,IoC中的可以,看来是我的问题了,继续研究`````
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 13:08:20 -0000
Local: Wed, Nov 15 2006 8:08 am
Subject: Re: 发布NBearV3.2.2 Beta
呵呵,好不容易解决刚才的那个问题,又有一个逻辑问题出现:
看看这段Insert脚本,是在Insert
User之后的,使用了Int自增主键,所以Insert
Profile时,UserID就为0了。
这是不是说明,这种外键关联,不能使用Int自增呢?
Text INSERT INTO [UserProfile] ( [Content], [LastIP], [User_ID] )
VALUES ( @Content, @LastIP, @User_ID ); SELECT SCOPE_IDENTITY()
Parameters:
@Content[String] = mk2profile
@LastIP[String] = 00000
@User_ID[Int32] = 0
`````是不是我太多问题了???
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 21:12:53 +0800
Local: Wed, Nov 15 2006 8:12 am
Subject: Re: 发布NBearV3.2.2 Beta
你的测试很认真,非常感谢才是~~ :)
你这个User_ID[Int32] = 0是3.2.3的吗?你可以试试ORM_Tutorail教程中的代码,就是UserProfile的情形, 这样的关联属性在v3.2.2之前不会被自动赋值,所以会有你这个错误。但是v3.2.3中应该已经修复了。
On 11/15/06, feng... @gmail.com <feng... @gmail.com> wrote:
> 呵呵,好不容易解决刚才的那个问题,又有一个逻辑问题出现: > 看看这段Insert脚本,是在Insert > User之后的,使用了Int自增主键,所以Insert > Profile时,UserID就为0了。 > 这是不是说明,这种外键关联,不能使用Int自增呢? > Text INSERT INTO [UserProfile] ( [Content], [LastIP], [User_ID] ) > VALUES ( @Content, @LastIP, @User_ID ); SELECT SCOPE_IDENTITY() > Parameters: > @Content[String] = mk2profile > @LastIP[String] = 00000 > @User_ID[Int32] = 0
> `````是不是我太多问题了???
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
MK2 <feng... @gmail.com>
Date: Wed, 15 Nov 2006 21:23:27 +0800
Local: Wed, Nov 15 2006 8:23 am
Subject: Re: 发布NBearV3.2.2 Beta
我是用V3.2.3的,我用Guid类型做主键时,UserProfile的User_ID是正确的,但User中使用int 自增做主键时,UserProfile中的User_ID则为0. NBear帮我解决了很多底层数据映射问题```太感谢你的工作``````还有这么贴心的回复
On 11/15/06, Teddy <shijie... @gmail.com> wrote:
> 你的测试很认真,非常感谢才是~~ :)
> 你这个User_ID[Int32] = 0是3.2.3的吗?你可以试试ORM_Tutorail教程中的代码,就是UserProfile的情形, > 这样的关联属性在v3.2.2之前不会被自动赋值,所以会有你这个错误。但是v3.2.3中应该已经修复了。
> On 11/15/06, feng... @gmail.com <feng... @gmail.com> wrote:
> > 呵呵,好不容易解决刚才的那个问题,又有一个逻辑问题出现: > > 看看这段Insert脚本,是在Insert > > User之后的,使用了Int自增主键,所以Insert > > Profile时,UserID就为0了。 > > 这是不是说明,这种外键关联,不能使用Int自增呢? > > Text INSERT INTO [UserProfile] ( [Content], [LastIP], [User_ID] ) > > VALUES ( @Content, @LastIP, @User_ID ); SELECT SCOPE_IDENTITY() > > Parameters: > > @Content[String] = mk2profile > > @LastIP[String] = 00000 > > @User_ID[Int32] = 0
> > `````是不是我太多问题了???
--
能Web就Web.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 21:46:43 +0800
Local: Wed, Nov 15 2006 8:46 am
Subject: Re: 发布NBearV3.2.2 Beta
的确又发现了个很难发现的bug,估计是这个bug导致你遇到的错误,多亏你的测试!~~
Teddy
On 11/15/06, MK2 <feng... @gmail.com> wrote:
> 我是用V3.2.3的,我用Guid类型做主键时,UserProfile的User_ID是正确的,但User中使用int > 自增做主键时,UserProfile中的User_ID则为0. > NBear帮我解决了很多底层数据映射问题```太感谢你的工作``````还有这么贴心的回复
> On 11/15/06, Teddy <shijie... @gmail.com> wrote:
> > 你的测试很认真,非常感谢才是~~ :)
> > 你这个User_ID[Int32] = 0是3.2.3的吗?你可以试试ORM_Tutorail教程中的代码,就是UserProfile的情形, > > 这样的关联属性在v3.2.2之前不会被自动赋值,所以会有你这个错误。但是v3.2.3中应该已经修复了。
> > On 11/15/06, feng... @gmail.com < feng... @gmail.com> wrote:
> > > 呵呵,好不容易解决刚才的那个问题,又有一个逻辑问题出现: > > > 看看这段Insert脚本,是在Insert > > > User之后的,使用了Int自增主键,所以Insert > > > Profile时,UserID就为0了。 > > > 这是不是说明,这种外键关联,不能使用Int自增呢? > > > Text INSERT INTO [UserProfile] ( [Content], [LastIP], [User_ID] ) > > > VALUES ( @Content, @LastIP, @User_ID ); SELECT SCOPE_IDENTITY() > > > Parameters: > > > @Content[String] = mk2profile > > > @LastIP[String] = 00000 > > > @User_ID[Int32] = 0
> > > `````是不是我太多问题了???
> -- > 能Web就Web.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Wed, 15 Nov 2006 22:04:07 +0800
Local: Wed, Nov 15 2006 9:04 am
Subject: Re: 发布NBearV3.2.2 Beta
已经更新到v3.2.4,辛苦再试一下你的程序,应该能修复这个问题。
On 11/15/06, Teddy <shijie... @gmail.com> wrote:
> 的确又发现了个很难发现的bug,估计是这个bug导致你遇到的错误,多亏你的测试!~~
> Teddy
> On 11/15/06, MK2 <feng... @gmail.com> wrote:
> > 我是用V3.2.3的,我用Guid类型做主键时,UserProfile的User_ID是正确的,但User中使用int > > 自增做主键时,UserProfile中的User_ID则为0. > > NBear帮我解决了很多底层数据映射问题```太感谢你的工作``````还有这么贴心的回复
> > On 11/15/06, Teddy <shijie... @gmail.com> wrote:
> > > 你的测试很认真,非常感谢才是~~ :)
> > > 你这个User_ID[Int32] = 0是3.2.3的吗? > > > 你可以试试ORM_Tutorail教程中的代码,就是UserProfile的情形,这样的关联属性在v3.2.2之前不会被自动赋值, > > > 所以会有你这个错误。但是v3.2.3中应该已经修复了。
> > > On 11/15/06, feng... @gmail.com < feng... @gmail.com> wrote:
> > > > 呵呵,好不容易解决刚才的那个问题,又有一个逻辑问题出现: > > > > 看看这段Insert脚本,是在Insert > > > > User之后的,使用了Int自增主键,所以Insert > > > > Profile时,UserID就为0了。 > > > > 这是不是说明,这种外键关联,不能使用Int自增呢? > > > > Text INSERT INTO [UserProfile] ( [Content], [LastIP], [User_ID] ) > > > > VALUES ( @Content, @LastIP, @User_ID ); SELECT SCOPE_IDENTITY() > > > > Parameters: > > > > @Content[String] = mk2profile > > > > @LastIP[String] = 00000 > > > > @User_ID[Int32] = 0
> > > > `````是不是我太多问题了???
> > -- > > 能Web就Web.
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
MK2 <feng... @gmail.com>
Date: Wed, 15 Nov 2006 22:52:46 +0800
Local: Wed, Nov 15 2006 9:52 am
Subject: Re: 发布NBearV3.2.2 Beta
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
"feng... @gmail.com" <feng... @gmail.com>
Date: Wed, 15 Nov 2006 17:40:07 -0000
Local: Wed, Nov 15 2006 12:40 pm
Subject: Re: 发布NBearV3.2.2 Beta
终于成功了`````呵呵,感谢Teddy的快速修复````
还有就是,如果在一对一关联中,如果User中有一个Profile引用,而Profile中有一个User的引用,无论是否LazyLoad=false或者 true,在Serialize(user)时,都会出现死循环。
一对一外键关联:这里使用了Profile.UserID做外键。 Text INSERT INTO [UserProfile] ( [Content], [LastIP], [UserID] ) VALUES ( @Content, @LastIP, @UserID ); SELECT SCOPE_IDENTITY() Parameters: @Content[String] = mk2profile @LastIP[String] = 00000 @UserID[Int32] = 1
Serialize(user): <?xml version="1.0" encoding="utf-16"?> <User xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xmlns:xsd="http://www.w3.org/2001/XMLSchema "> <ID>1</ID> <Name> <FirstName>MK2</FirstName> <LastName>Feng</LastName> </Name> <Email>feng... @gmail.com</Email> <Profile> <ID>1</ID> <Content>mk2profile</Content> <LastIP>00000</LastIP> <UserID>1</UserID> </Profile> <Groups /> <Roles /> <Tags /> <Contents /> <Comments /> <Categories /> <Status>Availate</Status> <LogOnName>fengmk2</LogOnName> <Password>222</Password> <PassQuestion>kkk</PassQuestion> <PassAnswer>ddd</PassAnswer> <Phones /> <No>333</No> <Birthday>2006-11-16T01:33:26.78125+08:00</Birthday> <CreateDate xsi:nil="true" /> <LogOnDate>2006-11-16T01:33:26.78125+08:00</LogOnDate> <LogOnCount>0</LogOnCount> </User>
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
Teddy <shijie... @gmail.com>
Date: Thu, 16 Nov 2006 06:44:40 +0800
Local: Wed, Nov 15 2006 5:44 pm
Subject: Re: 发布NBearV3.2.2 Beta
如果该类可能被序列化,则必须在User和Profile的至少一个属性上标注SerializationIgnoreAttribute,这个我有在教程里说 明。否则就会死循环的。
Teddy
On 11/16/06, feng... @gmail.com <feng... @gmail.com> wrote:
> 终于成功了`````呵呵,感谢Teddy的快速修复````
> 还有就是,如果在一对一关联中,如果User中有一个Profile引用,而Profile中有一个User的引用,无论是否LazyLoad=false或者 true,在Serialize(user)时,都会出现死循环。
> 一对一外键关联:这里使用了Profile.UserID做外键。 > Text INSERT INTO [UserProfile] ( [Content], [LastIP], [UserID] ) VALUES > ( @Content, @LastIP, @UserID ); SELECT SCOPE_IDENTITY() > Parameters: > @Content[String] = mk2profile > @LastIP[String] = 00000 > @UserID[Int32] = 1
> Serialize(user): > <?xml version="1.0" encoding="utf-16"?> > <User xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " > xmlns:xsd="http://www.w3.org/2001/XMLSchema "> > <ID>1</ID> > <Name> > <FirstName>MK2</FirstName> > <LastName>Feng</LastName> > </Name> > <Email>feng... @gmail.com</Email> > <Profile> > <ID>1</ID> > <Content>mk2profile</Content> > <LastIP>00000</LastIP> > <UserID>1</UserID> > </Profile> > <Groups /> > <Roles /> > <Tags /> > <Contents /> > <Comments /> > <Categories /> > <Status>Availate</Status> > <LogOnName>fengmk2</LogOnName> > <Password>222</Password> > <PassQuestion>kkk</PassQuestion> > <PassAnswer>ddd</PassAnswer> > <Phones /> > <No>333</No> > <Birthday>2006-11-16T01:33:26.78125+08:00</Birthday> > <CreateDate xsi:nil="true" /> > <LogOnDate>2006-11-16T01:33:26.78125+08:00</LogOnDate> > <LogOnCount>0</LogOnCount> > </User>
You must
Sign in before you can post messages.
You do not have the permission required to post.